I have a solution in Visual Studio 2010 that includes a test project that uses WatiN. It also has a test project with unit tests. Both use NUnit as the framework. I use Gallio to run/debug the tests.
I'm trying out Visual Studio 2012. My project builds fine. I can use the NUnit GUI to run both sets of tests. The Test Explorer lists all tests (unit and UI). I can run/debug the unit tests from within Visual Studio.
When I run the UI tests from within Visual Studio 2012 I get an error:
The CurrentThread needs to have it's ApartmentState set to
ApartmentState.STA to be able to automate Internet Explorer.
The error occurs on the following line in my TestFixtureSetup function:
browser = new IE(...);
I've Googled the error and seen plenty of suggestions about adding lines to the app.config. The odd thing is that I already have those lines.
<sectionGroup name="NUnit">
<section name="TestRunner"
type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
...
<NUnit>
<TestRunner>
<!-- Valid values are STA or MTA (Others are ignored) -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
Has anyone gotten WatiN working with the Test Explorer in Visual Studio 2012? Any suggestions for getting it to work? Are there known compatibility issues?
I also tried installing Gallio with the RC and it broke some things that required a bit of effort to fix. I would prefer to use the integrated Test Explorer.
Found a solution here.
I added the following to my AssemblyInfo.cs file:
[assembly: RequiresSTA]
Still outstanding is why doesn't the test runner see the STA settings in the app.config?
Related
When attempting to link up a test in Visual Studio to Microsoft Test Manager (MTM) via the "Associated Automation" tab, the tests created in visual studio aren't showing up.
This is an issue with a number of projects in the solution. I have tried re-building the solution but they still do not display. Some show, some don't. What could be the issue with this occurring and how can this be remedied?
The issue was being that if the projects were not created as a variation of any of the "Test" projects in Visual Studio, the tests won't show up on the associated automation test names when linking to the MTM test case.
I have a seperate MSTest project that runs tests against two other c# projects within the same solution. The tests are all MSTests and run succesfully in both the Visual Studio Test Explorer and Resharper (with MSTest set). Both are using my *.testsettings file that specifies the dependencies. Trying to get dotCover to generate coverage results gives me a FileNotFoundException on both the ddls from the referenced projects. This is similar to the exception I got with VS Test Explorer before adding dependencies in the testsettings file. Both dotCover and Resharper have the same test settings in options. Any ideas why dotCover cannot resolve the dependencies when Resharper can?
I've come across the same problem and had to do the following to get Resharper running dotCover again correctly for my solution:
Delete the resharper cache for your solution. It will be located something like :
%LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVs14\v09\SolutionCaches\{folder with solution name in it}
Numbers may be different based on which version of Resharper you have (I have 2017.2 Ultimate).
Delete the visual studio solution cache:
{solutionfolder}\.vs\{solutionname}\v14\*.suo
Again, numbers depend on which version of visual studio you have (I have VS2015)
Finally, you may have to give a hint in the test project files to run the correct version of the .net framework. Insert the following into the <configuration> node of your app.config file in your test project(s):
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
Again, your supported runtime depends on which version of the .net framework your project is configured to use (in my case, .net 4.5.2).
Test which use Microsoft Fakes Framework fail with exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables
VS solution and builds were originally created in VS 2012 and run fine under TFS 2012 build/ controller, but not under TFS 2013. I do have Ultimate VS 2012 and Ultimate VS 2013 installed on TFS 2013 build server. While troubleshooting this issue, I changed test setting in the build definition from using "Visual Studio Test Runner" to "MSTest.exe Test Runner (VS 2010 Compatible)", and now not able to change it back as "Visual Studio Test Runner" is no longer an option in the drop-down of choices. I even replaced build template in TFS 2013 with the one in TFS 2012 but "Visual Studio Test Runner" is still not an option in the drop-down of choices in the build definition Process\Automated Tests section while editing Test Run.
How to solve the problem and get the tests which use Microsoft Fakes to run in TFS 2013 build?
I was having this exact same problem and it turned out that I had a .testsettings file created in my solution and was telling the test runner in the IDE to use it. If you are getting this error in the Visual Studio IDE, verify that you do not have a .testsettings file specified by going under the Test menu -- if there is a .testsettings file specified with a checkmark next to it, click it to remove the checkmark. I suspect the presence of the .testsettings file causes Visual Studio to initialize the test runner differently.
If this is happening on the build server, verify that your build definition does not have a .testsettings file specified; ideally, perhaps remove the file altogether from source control and/or your solution. The presence of this file can trip up a TFS build.
I got the exact same error, but in my case it was a bug in ReSharper 2017.3.1:
https://youtrack.jetbrains.com/issue/RSRP-467796
Already fixed in ReSharper 2018.1
I am using Visual Studio 2012, but TFS 2010.
I have created a build with the default build template, that builds several C# solutions, runs tests, etc. At present, many of the unit tests fail. I can see from the build log that MSTEST has successfully published the build results to the TFS server.
BTW, the build was a "Partial Success". I would like to know why. That's why I'm looking for the test results.
In Visual Studio 2010, I would have used the Test Results and Test Runs windows to load the published results. These windows are missing in Visual Studio 2012. How can I get access to my test results (preferably without installing Visual Studio 2010).
Also, the full build log is not copied to the drop folder. Is there some way for me to find out what caused the "Partial Success"?
P.S. This is Visual Studio Professional 2012.
UPDATE
So, it says "Publishing results of test run ... to url". How do I get to see the test results?
View Menu -> Other Windows -> Test Results
I'm running Visual Studio 2012 RC (all the latest updates have been installed as of 7/11/2012. I have an asp.net mvc 4 solution with
a Web Project
a Unit Test Project
a Coded UI Test Project
a Web performance and load Test project
When I first created the solution I could add Coded UI Tests with no problem. However, today I tried to create a Coded UI Test and got the following error
The following package failed to load: C:\Users[File Path Goes
Here]\Microsoft.VisualStudio.TestTools.UITesting.dll. Coded UI Test is
now in an inconsistent state. Remove this package and restart Visual
Studio to work with Coded UI Test.
I had a similar problem before with Visual Studio 2010. I still have that problem for that matter.
However, if I uninstall (via NuGet) MVC Scaffolding and T4Scaffolding and restart Visual Studio I can create Coded UI Tests again, but if I add back in the scaffolding packages and restart Visual Studio I get the error again and cannot create the Coded UI test.
It seems that
there is a conflict between the scaffolding packages and Coded UI Tests in Visual Studio
The original error Visual Studio 2010 error has not been fixed in Visual Studio 2012 - Microsoft has acknowledged that this is a bug.
Can anyone help this fan of scaffolding and Coded UI Tests? It would be great to use both technologies without workarounds.
There is no solution to this. The only real workaround is not to use MVC Scaffolding.