Why is my unit testing is not working?

0

I'm using vs17, Whenever I run any of the tests I get this

[4/5/2018 12:10:19 PM Informational] ------ Run test started ------ [4/5/2018 12:10:19 PM Warning] [MSTest][Discovery][C:*path*\bin\Debug\FeatureFlags.API.Tests.dll] The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) [4/5/2018 12:10:19 PM Warning] No test is available in C:*path*\bin\Debug\FeatureFlags.API.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. [4/5/2018 12:10:19 PM Informational] ========== Run test finished: 0 run (0:00:00.7650001) ==========

I feel the need to ensure that I have searched for this problem in tons of other questions and other sites and non of the solutions solve my problem, and most of them is either very old questions or for vs15 before update 2 where it solves the problem or prior to framework 4.6 and I'm currently using framework 4.7. and I can't downgrade my framework version.

I've added a .runsettings file, used debugging " it never hits the break points or even start to run anything", I have changed the default processor architecture, and I've disabled "Enable just my code", none of that worked for me. I rebuilt the solution a lot of times and even did closed the visual studio and restarted my pc.

In the debugging mode, I can see in the output windows

"Cannot find or open the PDB file"

a lot of times for different files.

What is my mistake and how to solve this?

EDIT 1 here is an example of my test cases

[TestClass]
public class VezeetaFeatureFlagsTests
{
    private readonly FeatureFlagController _controller;

    public VezeetaFeatureFlagsTests()
    {
        MockHttpContext();
        _controller = new FeatureFlagController(new FeatureFlagCore(new FeatureFlagDAL(new RedisClient("FeatureFlags.RedisConnectionString"))));
    }

    private void MockHttpContext()
    {
        HttpContext.Current = new HttpContext(
            new HttpRequest("", "http://localhost:2812/", ""),
            new HttpResponse(new StringWriter())
        );

        Path.Combine(@"*Path*", "");

    }

[TestMethod]
    public void Valid_AddKey()
    {
        List<AddTagsAndFeaturesModel> addTagsAndFeaturesModels = new List<AddTagsAndFeaturesModel>
        {
            new AddTagsAndFeaturesModel()
            {
                Key = "test",
                Values = new List<object>()
            {
                "Feature 1",
                "Feature 2"
            },
                IsHide = false,
                IsTags = false
            }
        };

        var result = _controller.AddFeaturesOrTags(addTagsAndFeaturesModels);

        Assert.AreEqual(result.StatusCode, HttpStatusCode.OK);

    }

} and I can see it in the test explorer.

c#
visual-studio
unit-testing
asked on Stack Overflow Apr 5, 2018 by Islam Hamed • edited Apr 5, 2018 by Islam Hamed

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0