nunit

Additional log output on NUnit test fail

我们两清 提交于 2020-01-24 18:06:53
问题 Whenever an NUnit test fails during its execution (i.e. not when using Assert.* ), I want to log additional information (I'm writing web tests and I am especially interested in the web page's current DOM). How to specify a global exception handler in NUnit which is able to log additional information on NoSuchElementException s - test should still fail of course. 回答1: You could write an NUnit event listener addin that logs the information. See http://www.nunit.org/index.php?p=nunitAddins&r=2.6

Vstest.console.exe can't find nunit tests

痴心易碎 提交于 2020-01-24 05:03:40
问题 I have VS 2017 and .net 4.6 On trying to run via cmd prompt using vstest.console: vstest.console.exe bin\Release\Tests.dll /UseVsixExtensions:true I am getting warning "No test is available in /bin/Release/test.dll Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again." So, I tried listing the tests but it doesn't show any tests. vstest.console.exe bin\Release\Tests.dll /ListTests /UseVsixExtensions:true Unit tests class

How to set the value of a query string in test method Moq

对着背影说爱祢 提交于 2020-01-23 05:14:48
问题 I have the following controller action method and I am writing a unit test for this method try { if ( Session["token"] == null) { //checking whether the user has already given the credentials and got redirected by survey monkey by checking the query string 'code' if (Request.QueryString["code"] != null) { string tempAuthCode = Request.QueryString["code"]; Session["token"] = _surveyMonkeyService.GetSurveyMonkeyToken(ApiKey, ClientSecret, tempAuthCode, RedirectUri, ClientId); } else { //User

Running NUnit tests in Visual Studio 2010 with code coverage

不打扰是莪最后的温柔 提交于 2020-01-22 05:34:34
问题 We have recently upgraded from Visual Studio 2008 to Visual Studio 2010. As part of our code base, we have a very large set of NUnit tests. We would like to be able to run these unit tests within Visual Studio, but with code coverage enabled . We have ReSharper, so can run the tests within Visual Studio, but it does not allow the code coverage tool to do its thing and generate the coverage statistics. Is there any way to make this work, or will we have to convert the tests over to MSTest?

Unit Test Help. How do I test for a message output to console?

旧街凉风 提交于 2020-01-21 10:59:06
问题 I am a newbie to unit testing. How do I check the for console output? I have namespace XXShapes { public abstract class XXShape { public virtual void DrawXXShape() { Console.WriteLine("The XXShape was drawn."); } } public class XXCircle : XXShape { public override void DrawXXShape() { Console.WriteLine("The XXCircle was drawn."); } } } namespace XXShapes.Test { [TestFixture] public class XXShapeTest { [Test] public void MyFirstTest() { XXShape s = new XXCircle(); string expected = "The

Unit Test Help. How do I test for a message output to console?

我们两清 提交于 2020-01-21 10:58:48
问题 I am a newbie to unit testing. How do I check the for console output? I have namespace XXShapes { public abstract class XXShape { public virtual void DrawXXShape() { Console.WriteLine("The XXShape was drawn."); } } public class XXCircle : XXShape { public override void DrawXXShape() { Console.WriteLine("The XXCircle was drawn."); } } } namespace XXShapes.Test { [TestFixture] public class XXShapeTest { [Test] public void MyFirstTest() { XXShape s = new XXCircle(); string expected = "The

Selenium: Check i the testcase pass or fail

元气小坏坏 提交于 2020-01-17 05:37:09
问题 Guys First of all I am totally new for Selenium. I am having a automation project. In my project, I am creating a screenshot function to take screenshots of my event which I have created for my testcases. Now if my test cases passes then all screenshot should move to Pass folder, else fail folder. I would like to know how to detect that my test case pass? I know Nunit detects but I wanted to program it so that I cam place my screenshot as well as log file to pass or fail folder. Program in C#

Why isn't CruiseControl.NET emailing build and test results?

房东的猫 提交于 2020-01-17 03:34:18
问题 I'm using CruiseControl.NET with NUnit and NAnt. I'm trying to get CC.net to send out emails that contain the styled test results and build information. My config file looks like this: <publishers> <merge> <files> <file>C:\Tests\*Results*.xml</file> <file>C:\Artifacts\*</file> </files> </merge> <xmllogger logDir="C:\Build Logs" /> <email from="ContinuousIntegrationServer@test.com" mailhost="mail.test.com"> <groups> <group name="alwaysNotify"> <notification> <notificationType>Always<

NUnit/Moq: I have mocked a class but real contructor is executed, why?

橙三吉。 提交于 2020-01-16 01:53:49
问题 I have a large legacy WPF project that I'm now trying to get unit tested with NUnit (v. 2.6.3) and Moq (v. 4.2), but I'm having trouble with mocking certain classes. There's one in particular, a control class derived from System.Windows.Forms.Integration.WindowsFormsHost , that's needed all over the project and has a lot of external dependencies, so it's very important to be able to mock it. Let's call that class Foo , and here's the test case: [TestFixture,RequiresSTA] public class

'dotnet test' is not finding nunit tests in gitlab-runner pipeline

余生颓废 提交于 2020-01-15 09:26:08
问题 I have a solution with a NUnit testproject ( Foo.Test ). +-- src | +-- Foo.Gui | +-- Foo.Test <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.0</TargetFramework> <IsPackable>false</IsPackable> </PropertyGroup> <ItemGroup> <Compile Remove="TestResults\**" /> <EmbeddedResource Remove="TestResults\**" /> <None Remove="TestResults\**" /> </ItemGroup> <ItemGroup> <PackageReference Include="GitVersionTask" Version="5.1.2"> <PrivateAssets>all</PrivateAssets>