How to get a results file from Nunit Test Adapter ran in Visual Studio with Test Explorer - nunit

I have been running my tests with Specflow+ through Test Explorer in Visual Studio and a nice .html report is automatically generated at the end by the Specflow+ Runner.
I have switched to Nunit Test Runner (still running through Test Explorer).
However, at the end I can't see any results files at all xml or html?
How do I get it to generate these? Or am I looking in the wrong place?
I tried adding a .runsettings file in the root of the project containing the following code but still no results were written:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<NUnit>
<TestOutputXml>TestResults</TestOutputXml>
</NUnit>
</RunSettings>

It's necessary to tell TestExplorer to use the .runSettings file. See https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019

Related

Code Coverage with Visual Studio Test task

I have a project containing azure function implementations. My project .csproj file looks like below.
I haved added a test project for the same and implemented unit tests using Xunit. My test project .csproj looks like below.
I have added a Visual Studio Test task in my build definition with below configurations.
How can I include only project and test project for calculating code coverage?
You can use Run settings file which is the configuration file used by unit testing tools. Advanced code coverage settings are specified in a .runsettings file.
You can exclude specified assemblies from code coverage analysis. For example:
<ModulePaths>
<Exclude>
<ModulePath>Fabrikam.Math.UnitTest.dll</ModulePath>
<!-- Add more ModulePath nodes here. -->
</Exclude>
</ModulePaths>
Then add the .runsettings file in source control, specify the file under Setting file area in Visual Studio Test task
Please see Customize code coverage analysis for details.

False Error Message in Eclipse for Ant Include Task

In my ant build I am including a second ant build file (build.xml):
<project name="Including" default="echoC" basedir=".">
<include file="build.xml" as="Included"/>
<target name="echoC" depends="Included.echoB">
<echo>C</echo>
</target>
</project>
build.xml is in the same directory as the including build file and everything is working fine actually. I can run the target echoC and also the target echoB from the included build file is executed first.
What is irritating however is that Eclipse is displaying the error message Target Included.echoB does not exist in this project in the Ant Editor. Does anybody know how to get rid of that?
Thanks a lot for your support!
This seems a bug in Eclipse according to https://bugs.eclipse.org/bugs/show_bug.cgi?id=412809. The comments suggest there is no support for the task in the editor.
Using the import task instead works fine.

Web.config file for the contents and Scripts folder not copied while doing an msbuild to get the build package

I am working on a asp.net mvc2 project which has Contents folder containing images,css files and Scripts folder containing all the js libraries and files used in the project. I have a web.config file containing the code for enabling caching for the contents present within the Contents and Scripts folder as mentioned below:
Web.config:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<!--Caching-->
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" cacheControlCustom="must-revalidate"/>
<!--<clientCache cacheControlMode="UseExpires" httpExpires="Tue, 31 Dec 2030 12:00:00 GMT"/>-->
</staticContent>
</system.webServer>
</configuration>
I am using msbuild to get a package ready for deployment. I see the package is built successfully containing the MSI which I install in the server. After installing the MSI I see that there is no web.config present within the Contents and Scripts folder in the server.
I tried setting Copy to Output Directory = Copy Always in the properties section of the web.config file but still I don't see it in the Contents and Scripts folder in the server.
Can anyone help me to fix the issue?
Thanks & Regards,
Santosh Kumar Patro
From your question I assume you are building your MSI with the Visual Studio Web Setup Project. In that case, you also need to make sure your extra web.config files are included in the "File System" tab view of your installer project. Normally those would be part of "Content Files".

problem when adding crystarl reports references with nant

This is the problem. I have been trying to compile a simple desktop vb aplication using the solution task found in nant. When I compile it without crystarl reports controls it compiles ok, but when add a simple crystal report viewer It does not compile any more. I supose I have to make some kind of reference but since these assemblys are in the GAC like System.* assemblys they shouldn't be a problem.
This is the very simple code
<?xml version="1.0"?>
<project name="miPrueba" default="go">
<target name="go">
<solution configuration="debug" solutionfile="simple.sln"/>
</target>
</project>
thanks in advance
So, as I suspected, this was very simple. Here is what I did to fix it. Simply copy the dlls of crystal reports into the bin directory, delete the crystal references in the project, if any,and make the references again pointing to the bin directory.

App.config for SpecFlow not recognized by NUnit GUI runner

How do I get my App.config file to be recognized/used by the NUnit GUI runner? I have tried placing it in the top folder of my project and in the same folder as my feature files. Here are the contents of my App.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>
<specFlow>
<runtime detectAmbiguousMatches="true"
stopAtFirstError="false"
missingOrPendingStepsOutcome="Error" />
</specFlow>
</configuration>
Specifically I am trying to tell NUnit to have a fail result when there is a missing or pending step which is why I am specifying "Error" for this. This actually works correctly when I use TestDriven.net but not when I use the NUnit GUI runner. The GUI always shows a green bar and displays the test as Inconclusive instead of Error or Failed.
I am launching the GUI with this command line argument:
E:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe "E:\ACSreader new work\ACSreader2 Working Copy\trunk\ACSreader2\ACSreader2.sln" /config:Test
Update concerning NUnit GUI Runner:
NUnit-Runner seems not to properly display/report inconclusive tests. An inconclusive test is displayed green in NUnit-GUI, while TestDriven and ReSharper display it yellow.
As shown in the question, SpecFlow can be configured to report missing steps as Errors and not as Inconclusive.
The configuration happens in the App.config of the project that contains the feature-files. The usual mechanism for App.config in .NET is applied. That means at runtime the config info has to be in a file called .dll.config. The runtime provides then the config to SpecFlow. SpecFlow does not read the config itself from App.config!
Make sure that at runtime the correctly named config file is present alongside the dll that contains the test fixtures. VisualStudio usually does that transparently when building a project.
Original answer:
The App.config has to be in the root folder of the project that is containing the test-fixtures (the project that contains the feature files).
Have a look at the examples on github. There are several App.config files in different projects:
http://github.com/techtalk/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests/
http://github.com/techtalk/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests.Selenium/
http://github.com/techtalk/SpecFlow-Examples/tree/master/BowlingKata/BowlingKata-MsTest/Bowling.SpecFlow/
See my answer nunit and configs
You need to tell nunit what the name of the config file is. it looks for namespace.config by default it seams