I've got a really annoying problem with Visual Studio 2013 Professional - I've got two Unit Tests projects - one of them written in C#, and another written in C++. Both of them are standard Visual Studio Unit Tests projects. When I build both of them and turn on Test Explorer window, only C# test methods appears.
Test Explorer doesn't see any of native C++ test method.
First - I tried to rebuild specific project - didn't work. Then I tried to clean 'n rebuild entire solution - also didn't work.
Do you have any ideas how to solve that problem?
UPDATE (SOLUTION) - 03/03/2016
The problem was caused by C++\CLI project in Unit Tests references.
When I remove that project's reference and rebuild unit tests project, everything works fine and Test Explorer detects all of test methods.
Conclusion - something creepy happens when you are trying to test C++\CLI project in native Unit Tests using Visual Studio 2013 default unit tests template project, which is pretty amazing, because it should works - in normal C++ console application works completely fine.
Related
Neither the integrated test environment nor Resharper won't run any unit tests.
When starting Visual Studio the Test Output Pane shows 10+ lines stating:
An exception was thrown while initializing part "Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider".
This is what I've tried so far:
Clear folder %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Create a simple test project with one class library, one class and one test library containing one unit test for that class
Uninstallation and new installation of Visual Studio 2015
All actions didn't fix the problem. Even the simple test won't run.
Running tests from command line using MSTest does work.
Ensure that your anti-virus programs are not quarantining Visual Studio components.
I had this problem when our corporate IT department changed our Sophos Protection Quarantine policy. VS2015 Unit testing stopped working for everyone, with a similar error.
I am using VS2012 (v110)
I create a simple dll application with only 1 function and a test project to test the dll function. I set up both projects to be debug builds for win32 and tried Clean and Rebuild both projects but I don't see any test to be run on the test Explorer windows.
I also reference Dll project in the test project already.
Why isn't there anything shown in Test Explorer windows?
Actually MSTest doesn't work with simple class library projects.
You will have to create a unit test project and place your tests there.
If you use other testing frameworks like NUnit, then you can use plain class library. You can then use NUnit to run the tests outside VS, or use tools like ReSharper to run those tests inside VS
It seems you have used some test frameworks other that MSTest. If you want to use Test Explorer for some other frameworks you should install its runner too. for instance NUnit needs to install its test adapter as and extension in VS.NET
see here for more.
You should be able to modify an existing class library project to get mstest to recognize it as a test project by modifying the ProjectTypeGuids in the .csproj file as detailed in this answer How to get VS2010 to recognize my mstests generated by SpecFlow? (Look for the answer that lists the specific guids and not the currently accepted answer which says to just create a new project.)
Have had a simular problem. Solved it. I have been adding tests project to my VS 2012 solution and tests were not appearing in Test Explorer. Problem was that test project was located in IIS inetpub\wwwroot folder which didn't have windows user rights to modify it. Adding solution folder Windows user rights to modify it solved issue. Tests are now visible in test explorer and able to be debugged. I assume that vstest.discoveryengine.exe process with is run by windows user was not having access to test project files
I have a visual studio project. I later added a .cs file for testing and have added the appropriate 'using' statements and [Test] and [Testfixture] attributes. When I open the nunit gui application, however, it only accepts .dll, .exe, and .nunit files. I was wondering what exact steps I need to take to execute the tests I wrote. Is it possible to do so directly in visual studio?
You should add the NUnit dll as a reference on your project.
JetBrains' Resharper is able to run the tests inside Visual Studio. Read more about Resharpers unittesting here. JetBrains has also developed a line coverage tool: dotCover.
Right now, Resharper is the best solution.
Test Driven .Net is the best free solution I know of.
Visual Studio 11 will finally allow for 3rd part testing framework plugins.
I'm new to NUnit and I just download it today and I can't get it working with visual studio. (I'm new to Visual Studio as well)
I'm following TekPub's Mastering C# 4.0 tutorial.
Screenshot: Something is missing within the red circle area. There should be some "green thing" on the side that let you double click on it and run the NUnit test.
http://dl.dropbox.com/u/20422001/NunitMissing.jpg
As you can see on the above screenshot, the NUnit seems not working....
Did I miss something? Please advice. Thanks
EDIT
This is how it SHOULD look like. I took a screenshot from the video tutorial:
http://dl.dropbox.com/u/20422001/nunit.jpg
and here is the project files:
http://dl.dropbox.com/u/20422001/MasteringCSharp.rar
As you can see, I don't have "Unit Test" Tab and "Unit Test Session"...
You aren't doing anything wrong. Out of the box, NUnit doesn't integrate directly with Visual Studio. The screenshot from the video appears to be using Resharper's test runner.
Typically testing with NUnit requires you to compile your test project and then load it into the NUnit GUI (nunit.exe) where the tests can be run from there. When using the NUnit GUI, the project will reload anytime the assembly is recompiled. (I sometimes prefer having this in a separate process as it doesn't tie up Visual Studio's UI, but that's a matter of preference.)
The added advantage of using a third party test runner like Resharper, TestDriven.net, Galileo, etc is that it allows you to run or debug the tests directly from within the IDE. You can accomplish the same thing using NUnit by configuring Visual Studio to attach to NUnit and debug your tests from the external process. This post shows you how.
I haven't seen that particular video, but it sounds like you need an NUnit test runner for Visual Studio.
Check out the following:
Visual NUnit 2010 - free!
TestDriven.net
ReSharper
That my friend is JetBrains' Resharper - it's a paid add-in to Visual Studio that allows you to run tests from within the IDE. Highly recommended if you're working for a prolonged period in VS.
Of course since you're just starting out, you could use the NUnit GUI to run your tests. You can also set it to run tests after each build.
Tools > Settings > Test Loader > Assembly Reload. Check "Re-Run last tests run". Apply changes
I am working on a class library (DLL) project in Visual Studio 2008; programming in C#. In order to test my DLL I just created a second project that is a console application and in that project I can reference the first and run tests. Is there a simpler way of doing this? Can I just create another file within my class library project that has the tests in it and then somehow tell Visual Studio to run that file?
I know one way would be to add a text file to my project and then write my test code in JScript. Then in the Project settings on the debug menu I can tell it to Start External Program (JScript). Then, the name of my test file, test.js, goes in the Command Line Arguments box. But, I am wondering if there is a way to do it using C# code instead of JScript?
You could add a testing project to your current solution, then set that project as the startup project. Then, hitting F5 on your class library project will start your testing project.
Take a look at NUnit or other similar unit testing framework.
The "Team Developer" and "Team Suite" flavors of Visual Studio already have Microsoft's unit testing framework built in.
Create a unit test project for the class library by using the right-click "Create Unit Tests" in a class/method in the library. I would recommend downloading TestDriven.NET and using the right-click test runner in it.
Are you talking about unit tests? You can use something like nUnit or the built in testing framework that comes with Visual Studio. The simplest tests just require you to add some attributes to your test fixture and make an assertion like obj1 == obj2.
Checking out something like Test-Driven Development (TDD), Domain-Driven Development (DDD) or Behavioral-Driven Development (BDD) may be beneficial. I like to use nUnit with nBehave, myself.