second project not showing tests in test explorer - unit-testing

I have a solution with a test project in it, based on nUnit. All of the tests I created show in the test explorer window, I can execute, etc.
I added another unit test project to the solution, created references exactly like the first project, same nUnit version, same Platform target (Any CPU), same code structure, etc., just for a different product. But I added tests (with Test attribute) to that project and they don't show in the Test Explorer.
All of my tests in the original project still show but no tests in my new project show.
How do I get tests from multiple projects to show in the Test Explorer window?
Is the Test Explorer window tied to a specific project?

I spent a day trying to figure this out but once I posted the question, as luck would have it, I figured out the solution. I changed the nUnit version back to 3.7.1.0 and it works - both projects now show tests in the Test Explorer window.

Related

UWP Unit Test App Blank

I've created a UWP Unit Test App in the past and remember it working fine.
I just tried to create a new one from scratch and hit F5 (no references, one empty test method) - out of box template.
I get a successful compile and launch, however the app window is empty and does not present the UWP testing UI.
Is this a known issue, or some basic prerequisite I've overlooked?
I'm running Visual Studio 15.5.5 on Windows 10 1709 (16299.192)
Thanks
-John
The Unit Test App should not be launched directly, instead it should run through the Test Explorer. In Test menu, choose Windows, and then choose Test Explorer. In the Unit Test Explorer window click Run all. This should execute all your tests. For more information follow the walkthrough here.

Get test list in MSTest via Command-Line [duplicate]

I just installed Visual Studio 2013 Premium and was having a good time playing with it and writing unit tests (using MS unit tests). However, the "Test Lists" window and some other Test related windows suddenly disappeared AND they have disappeared from the menu item
Test->Windows. In fact I remember Test->Windows having 4 items under it and now I only see two: Test Explorer, Code Coverage Results. i stress they WERE present in Visual Studio 2013. Clearly, I hit some key combination that made them disappear or something happened to make them disappear. How do I get Test List back? Please don't see they are under Tests->Windows, because for me, they are not (at least now. they were!)
Anyone else seen this? Any solutions? I tried restarting Visual Studio, rebooting.
Also, previously, under the "Test" menu, there was a Debug->"Test in Context" and a Run->"Test in Context", or something like this. It was very handy. If your cursor was with in some test, you could run just that one. I'm guessing this is related.
For all I know, these features have been "optimized" into the new test-window... a.k.a. they have been removed. Some other unit test related features are also gone (the context menu item for "create unit tests" is gone for example, yet can still be called via the command window)
Personally I think this is Microsoft's way of pushing everybody towards the Team Foundation Server but that's just my two cents.
I just had the same issue. In my case I needed to install the NUnit plugin ("Nunit test adapter"). After restarting the tests came back.
Start Developer Command Prompt:
cd to UnitTest-folder\bin\Debug which contains .dll
enter command: mstest /testcontainer:UnitTestMyTest.dll
(this creates the test-result)
in VS:
menu View / Other Windows / Test Results
manage Test Runs: window Test Runs -> connect to Test Run
browse to test-folder\bin\Debug\TestResults

Windows 10 Universal App Unit Testing project

I can't seem to find any information on this.. I am using it to test my Universal app but it comes with a XAML file and when I run the Unit Test it opens some screen... What is that for ? I don't need that.. I just want to unit test my code.
I think that the xaml file has something in common with UI tests, but you can still add some unit tests into that project and run them, it will start the application and blank screen will be displayed for a moment, but unit tests will run too.

Windows 8 App in Visual Studio 2012 - NUnit Test Adapter sees unit tests but does not run them

I have a Windows 8 Store App with two projects within the solution - one project exclusively for tests. I have added NUnit and NUnit Test Adapter (https://www.nuget.org/packages/NUnitTestAdapter/1.0.0) for this through nuget.
My tests are detected - but I cannot run or debug them. Looking at the test output window, I get the following error:
Could not find test executor with URI 'executor://nunittestexecutor/'. Make sure that the test executor is installed and supports .net runtime version 4.0.30319.34003.
I am not using resharper and I am using Visual Studio Professional 2012 Update 3 on Windows 8.1. References for the test project are as follows:
Based on my comments above, below is a workaround. Unfortunately at this stage, Windows 8.1 store Unit Test project types, using NUnit extension wouldn't work due to the different .NET targets. I tried with different Test Unit Adapters including an NUnitTestAdapterWithFramework.
It seems that the issue you haveing was occurring with standard .NET libraries targeting NUnit test adapter but the above NUnitTestAdapterWithFramework must have fixed those issue. See the Q & A section of the NUnitTestExtension
But unfortunatly it seems that this still of an issue that hasn't been fixed for Win8 Store App type Unit Testing. Pretty sure xUnit.NET also not compatible yet with different .NET target types (i,e WinRT)
So what are the options?
a. For your group, you can change them to use MSTest framework. Outcome - Problem Solved no issues.
b. Workaround "linked project". Outcome - Can't *guarantee** but this should also work.
With option 'b'
In your comment you mentioned.
but I'm still not sure what it does or how to implement a 'linked
project', do you have any more information on this? Also, as this is
for a group university project, I was hoping i wouldn't have to force
too many workarounds
When you think about it, it is not really hard work around. It is simple and I'm sure your group would be able to apply this workaround easily.
Please follow the below steps.
Create a separate class library in your solution (you can target .NET framework 4).
Then add NUnit assemblies and the NUnit test adapter as usual.
Right click on this project and select 'Add' then 'Existing Item'
Select the Win8 Store Unit Test project and locate the Unit Test file you want to add. When you add the file, make sure you select 'Add As a Link' button. Please see below.
Now rebuild the solution, close and re-open the UnitTest explorer and you should be able to run those tests.
*The reason I said can't guaranteed. I haven't really written Unit tests against Win8 App. So if your SUT (System Under Test) require special configuration it might cause issues. But I'm not sure.
Finally creating a link files are not that hard if everything works you can continue to do this until NUnit has the support for Win8 Unit Testing. Or the other option is simply change all your Unit Tests to use MSTest framework if possible.

Running unit tests

In our solution we have several test projects. Most of them contain unit tests that run fast but some are for integration, acceptance and UI tests which take quite some time to finish.
Now I'd like to have a convenient way of running only the unit tests. Either by using the hotkey to run all or using the new feature to run tests after each build.
Unfortunately VS also runs all the slow tests as well. In VS10 I grouped the tests in Test View by project and selected only the ones containing unit tests. It's not as easy as I wished it to be but at least it was possible. Now there doesn't seem to be a way around running all tests in a solution.
The only alternative that I see at the moment is to remove all but the unit tests from the solution but this would limit the refactoring capabilities.
So does anyone know how to easily group and run only unit tests in the new VS?
In Visual Studio 2012 Update 1 CTP, Test Explorer has added the option to group tests by Project or Traits (Categories).
Please go to this link to see what's new there.
You can use the search filter in Unit Text Explorer.
In the new Test Exlorer shipped with 2012, you can group tests by 'Test Results', 'FileName',... etc but in RTM build group/search by 'TestCategory' is not present from Test Explorer. However there is a filter in commandline and TeamBuild based on TestCategory (Running selective unit tests in VS 2012 RC using TestCaseFilter) in VS2012.
From a member of VS dev Team, they understood the importance of this missing feature. It is in the backlog, and it should be available in furutre builds/updates.
The following blog provides more details: http://blogs.msdn.com/b/vikramagrawal/archive/2012/07/23/running-selective-unit-tests-in-vs-2012-rc-using-testcasefilter.aspx
As of Visual Studio 2012 Update 2 (currently on CTP) now we are able to run a subset of unit test using "Playlists" or based on "Lists & Classes". More information here: http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/30/first-ctp-for-visual-studio-update-2.aspx#playlists
Original Answer:
AFAIK, The new unit testing framework in VS2012 "supports selective execution based on filtering condition through TestCaseFilter". Unfortunately, currently there is not support to do this through the user interface but it is in the product group's backlog. You can use this approach through Test Build or command line. Please refer to the following blog: http://blogs.msdn.com/b/vikramagrawal/archive/2012/07/23/running-selective-unit-tests-in-vs-2012-rc-using-testcasefilter.aspx
EDIT: Following the MSDN documentation to use test categories to group tests.
http://msdn.microsoft.com/en-us/library/dd286595.aspx
Also, refer to this question: How to exclude certain tests in the Visual Studio 2012 Test Runner?
It shows an example of filtering based on the test path.
I'd recommend using TestDriven.Net. Group all Unit Testing projects in one solution folder, and all other tests in another. Then just right click the "Unit Tests" folder and choose "Run All Tests". I always favor this great test runner of the VS native testing tools.
Another approach is using NCrunch - It runs all you tests in the background while you code. It handles integration tests pretty well, as they run in parallel, in the background so it doesn't block you (you also choose which test projects are run). One catch though - I believe it doesn't support VS2012 yet, but probably soon.
I was also missing this feature... (We did the same as you did: grouping by project or sometimes by namespace). But I found that I could somehow workaround this using the test explorer search capabilities:
https://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx
In my case I could identify the specific tests I needed to run using the search filter on FullName (use dropdown on search box, or type FullName:"UnitTest")
Its not the same, but it works for me