Questions tagged [nunit]

NUnit is an open source unit testing framework for .NET and Silverlight written in C#. It serves the same purpose as JUnit or TestNG does in the Java world, and is one of many in the xUnit family.

Initially ported from JUnit, this xUnit based unit testing tool for was written entirely in and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages. The current production release, version 3, has been completely rewritten with many new features and support for a wide range of .NET platforms.

References

Tutorials

7425 questions
44
votes
7 answers

"Thorough", tutorial on setting up Jetbrain's TeamCity CI server

Does anyone know where I can find a good tutorial to walk me through how to setup TeamCity CI server? I am new to unit testing and the agile philosophy of development so I could use some help getting my feet wet. I'm working with Asp.NET code using…
Agile Noob
  • 2,305
  • 4
  • 24
  • 35
43
votes
2 answers

What is the difference if TestFixture attribute is used or not

I cant see any difference in behaviour for class that has TestFixture attribute and not. All TearDown and SetUp are working in the same way. Is there any reason except semantics for this attribute usage?
Sly
  • 15,046
  • 12
  • 60
  • 89
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
43
votes
3 answers

ExpectedException in nUnit gave me an error

I'm new to using Testing Tools on the .NET Framework, so I downloaded it from NuGet with help from ReSharper. I am using this Quick Start to learn how to use nUnit. I had just copied the code and an error came up on this…
Basheer AL-MOMANI
  • 14,473
  • 9
  • 96
  • 92
43
votes
11 answers

NUnit - cleanup after test failure

We have some NUnit tests that access the database. When one of them fails it can leave database in inconsistent state - which is not an issue, since we rebuild database for every test run - but it can cause other tests to fail in the same run. Is it…
bh213
  • 6,343
  • 9
  • 43
  • 52
42
votes
9 answers

Test events with nunit

I'm just starting with TDD and could solve most of the problems I've faced on my own. But now I'm lost: How can I check if events are fired? I was looking for something like Assert.Raise or Assert.Fire but there's nothing. Google was not very…
atamanroman
  • 11,607
  • 7
  • 57
  • 81
41
votes
1 answer

How to escape double quotes in as a parameter to an NUnit TestCase?

I tried writing the following TestCase for an NUnit test written in VB.net: ")> Public Sub GetNode_GivenSomeNodeId_ReturnCorrectNode(ByVal nodeId as String, …
Kjartan
  • 18,591
  • 15
  • 71
  • 96
41
votes
9 answers

Evaluate if two doubles are equal based on a given precision, not within a certain fixed tolerance

I'm running NUnit tests to evaluate some known test data and calculated results. The numbers are floating point doubles so I don't expect them to be exactly equal, but I'm not sure how to treat them as equal for a given precision. In NUnit we can…
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
40
votes
4 answers

Dynamically create tests in NUnit

Using Nunit, I want to be able to write a test fixture that will read all the filenames in a particular directory and create a test for each file. I could quite easily write one test method that scans through the directory and just does all the…
Ray
  • 45,695
  • 27
  • 126
  • 169
40
votes
7 answers

WatiN System.IO.FileNotFoundException Interop.SHDocVw

I have just started to receive the following error when running my WatIn tests. System.IO.FileNotFoundException : Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e' or one of its…
Gilbert Liddell
  • 1,203
  • 4
  • 14
  • 21
40
votes
1 answer

How can I get NUnit3TestAdapter to work with .Net Standard 2.0?

How can I get NUnit3TestAdapter to work with .Net Standard 2.0? I receive the following error: 1>C:\Nikeza\Mobile\Nikeza.Mobile\Tests\ExampleBased.fsproj : warning NU1701: Package 'NUnit3TestAdapter 3.9.0' was restored using …
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118
40
votes
5 answers

JetBrains Resharper 9 Ultimate Test Runner error: NUnit.Core.UnsupportedFrameworkException: Skipped loading assembly {MyAssembly}

This seems to be an error with the JetBrains Resharper 9.1 Ultimate Test Runner referencing an older version of NUnit. I am using NUnit 3.0 in my assembly. [Window Title] Unit Test Runner [Main Instruction] Unit Test Runner failed to run…
Pouya Barrach-Yousefi
  • 1,207
  • 1
  • 13
  • 27
40
votes
8 answers

NUnit vs Visual Studio 2010's MSTest?

I realise that there are many older questions addressing the general question of NUnit v MSTest for versions of Visual Studio up to 2008 (such as this one). Microsoft have a history of getting things right in their 3rd version. For MSTest, that is…
40
votes
4 answers

Is it possible to execute a method before and after all tests in the assembly?

I would like to built an nunit project for selenium ui automation. I would like to sign in to the site before running all tests (all of them) and to close the browser after running all tests (all of them). I can't use the SetUp since it related to…
boger
  • 553
  • 1
  • 5
  • 12
39
votes
7 answers

NUnit comparing two lists

OK so I'm fairly new to unit testing and everything is going well until now. I'm simplifying my problem here, but basically I have the following: [Test] public void ListTest() { var expected = new List(); expected.Add(new…
SOfanatic
  • 5,523
  • 5
  • 36
  • 57