Questions tagged [nunit-3.0]

Questions related with NUnit version 3.0, for Unit Testing.

Questions related with NUnit version 3.0, for Unit Testing.

503 questions
71
votes
3 answers

NUnit 3.0 and Assert.Throws

I am writing some unit tests with NUnit 3.0 and, unlike v2.x, ExpectedException() has been removed from the library. Based on this answer, I can definitely see the logic in trying to catch specifically where in the test one expects their system to…
Killnine
  • 5,728
  • 8
  • 39
  • 66
70
votes
5 answers

NUnit3: Assert.Throws with async Task

I am trying to port a test to NUnit3 and am getting a System.ArgumentException : 'async void' methods are not supported, please use 'async Task' instead. [Test] public void InvalidUsername() { ... var exception =…
tikinoa
  • 1,267
  • 2
  • 10
  • 14
43
votes
4 answers

How do I install NUnit 3 console on Windows and run tests?

I want to run tests from a console like this (being in any directory, the DLL file can be for a different .NET version): $ nunit3-console test.dll I googled a lot, but can't find how to set up this. The official tutorial has nothing useful and is…
one_mile_run
  • 3,264
  • 4
  • 26
  • 29
31
votes
2 answers

NUnit 3: Forbid tests to run in parallel

I have the latest NUnit(3.2.0) installed and I have all my tests run in parallel. It might look like desirable behavior but I didn't ask for it and actually it broke some of my tests. I have some initialization in [OneTimeSetUp] which is…
ixSci
  • 13,100
  • 5
  • 45
  • 79
28
votes
1 answer

Error `Async test method must have non-void return type` when upgrading from NUnit 2 to NUnit 3

I have to refactor am unit test from NUNIT 2 to NUNIT 3 and the following syntax throws an error: var expectedResponseMessage = new HttpResponseMessage(); Func> continuation = () => Task.Factory.StartNew(() =>…
Jake Manet
  • 1,174
  • 3
  • 15
  • 26
26
votes
4 answers

Multiple assertions using Fluent Assertions library

It seems that Fluent Assertions doesn't work within NUnit's Assert.Multiple block: Assert.Multiple(() => { 1.Should().Be(2); 3.Should().Be(4); }); When this code is run, the test fails immediately after the first assertion,…
YMM
  • 632
  • 1
  • 10
  • 21
23
votes
4 answers

Using an app.config file with NUnit3 in a .NET Core console app

The Environment: I've got three projects in my solution currently: A .NET Standard 2.0 library with some code I'd like to test. A .NET Core 2.2 console app that references the library to make sure it works. A .NET Core 2.2 console app created by…
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
23
votes
3 answers

view code coverage report on azure devops portal

I am running the NUnit tests (project in .Net Framework 4.5), as part of azure devops build pipeline. - task: VSTest@2 inputs: testAssemblyVer2: 'tests/**/*.Tests.dll' pathtoCustomTestAdapters: '$(Build.SourcesDirectory)/packages' …
harishr
  • 17,807
  • 9
  • 78
  • 125
22
votes
4 answers

How to fix Could not load file or assembly 'nunit.engine, Version=3.7.0.0

I have a webappliction with a separate test-project using NUnit to run unittests. When my test-project is trying to discover tests I run into the following exception: An exception occurred while test discoverer 'NUnit3TestDiscoverer' was loading…
Bunnynut
  • 1,156
  • 5
  • 14
  • 37
19
votes
4 answers

Unit Tests failing when I Run All Tests but pass when I Debug

I'm using NUnit3 in Visual Studio 2017 and doing TDD. Something really strange is happening since I updated my code to make my latest test pass. Now, 3 of my other tests are failing when I click Run All Tests, as below: It is telling me that the…
Michael Hennigan
  • 375
  • 2
  • 5
  • 15
19
votes
1 answer

Increase readability to assert IsNotNullOrEmpty with constraint-based asserts

I'm currently rewriting some unit tests to use NUnit 3 instead of NUnit 2 and need to change some asserts to contraint-based asserts. I have the following asserts: Assert.IsNullOrEmpty(result); That I've changed to: Assert.That(result,…
Torbjörn Hansson
  • 18,354
  • 5
  • 33
  • 42
18
votes
3 answers

ASP.Net Core 2.0 SignInAsync returns exception Value cannot be null, provider

I have an ASP.Net Core 2.0 web application I am retrofitting with unit tests (using NUnit). The application works fine, and most of the tests thus far work fine. However, testing the authentication/authorization (does a user get logged in and can…
t.j.
  • 1,227
  • 3
  • 16
  • 30
18
votes
2 answers

How can I enable trace output in NUnit 3's Visual Studio adapter?

Consider: [Test] public void Test1() { Trace.TraceInformation("Hello"); } When running it from Visual Studio 2015, the output window (Tests) shows no trace lines: ------ Discover test started ------ NUnit Adapter 3.4.0.0: Test discovery…
UserControl
  • 14,766
  • 20
  • 100
  • 187
17
votes
2 answers

NUnit: How to pass TestCaseData from a non-static method?

My test fails because of the message: The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method. This is my Code: const double MAX_DELTA = 0.01; Qv_ges qv_ges_NE; double Sum_Qv_ges_R_FL; Qv_ges…
Perazim
  • 1,501
  • 3
  • 19
  • 42
17
votes
8 answers

How to install nUnit 3 nunit3-console.exe in TeamCity 9.x

NUnit 3.0 is supported by TeamCity 9.1.x now however you have to install the runner and specify the path to the nunit3.console.exe in the step. My question is where do I copy the nunit3-console.exe? Do I have to put this on all the agents? Do I…
Brett Mathe
  • 6,429
  • 7
  • 23
  • 24
1
2 3
33 34