tagged [nunit]

What is a good, free C# unit test coverage tool?

What is a good, free C# unit test coverage tool? I'm looking for a tool that I can run against my code base to determine which areas of my code are covered by NUnit tests I've written. I would appreci...

Use NUnit Assert.Throws method or ExpectedException attribute?

Use NUnit Assert.Throws method or ExpectedException attribute? I have discovered that these seem to be the two main ways of testing for exceptions: Which of these would be best? Does one offer advanta...

Microsoft PEX with NUnit

Microsoft PEX with NUnit I am thinking of using Microsoft PEX tools for my project, but I would much rather use NUnit instead of MSUnit. Apparently, [PEX Extensions project](http://pex.codeplex.com) w...

13 Oct at 16:41

One-time initialization for NUnit

One-time initialization for NUnit Where should I place code that should only run once (and not once per class)? An example for this would be a statement that initializes the database connection string...

28 Jul at 22:36

Nunit test setup method with argument

Nunit test setup method with argument Can we have a test set up method with arguments? I need a different set up for every test in a fixture. Do we have something (or similar way) as the hypothetical ...

29 Apr at 10:22

How to run unit tests in STAThread mode?

How to run unit tests in STAThread mode? I would like to test an app that uses the Clipboard (WindowsForms) and I need the Clipboard in my unit tests also. In order to use it, it should run in STA mod...

15 Jan at 12:37

Run/Group Tests by Category Attribute of NUnit in Visual Studio

Run/Group Tests by Category Attribute of NUnit in Visual Studio I am trying to use the Category Attribute of NUnit with my Visual Studio Profession 2015. However, the attribute doesn't seem to be cate...

27 Oct at 01:40

When to use Assert.Catch versus Assert.Throws in Unit Testing

When to use Assert.Catch versus Assert.Throws in Unit Testing I'm just looking for some examples of when it is appropriate to use Assert.Catch or Assert.Throws for asserting any exceptions thrown in u...

12 Aug at 17:45

NUnit+ReSharper: How to view results for TestFixture with different parameters?

NUnit+ReSharper: How to view results for TestFixture with different parameters? I have written unit tests under NUnit that use TestFixtures with different parameters. Now, when I run tests, I want to ...

17 May at 09:25

Can I run NUnit tests from within Visual Studio 2010?

Can I run NUnit tests from within Visual Studio 2010? Is there an addon of some kind that will let me run and view results from inside Visual Studio? I remember there was some sort of icon with a red ...

C# NUnit TestCaseSource Passing Parameter

C# NUnit TestCaseSource Passing Parameter I have the following method which generates a set of test cases! How can I pass param which is of type string as a parameter to my `PrepareTestCases()` method...

20 Feb at 16:42

How can I load this file into an NUnit Test?

How can I load this file into an NUnit Test? I have the following IntegrationTest project structure ... ![enter image description here](https://i.stack.imgur.com/HRR0O.png) If i wish to use that test ...

21 May at 08:35

Run Individual Test from Nunit3-console.exe

Run Individual Test from Nunit3-console.exe when i run The Console Runner Runs all my tests. what command do i need to run in order to run individual tests? i tried it says that I am using an invalid ...

18 May at 11:9

nunit not working in windows 7 at all

nunit not working in windows 7 at all I am new to unit testing and this ism y first time trying NUnit. My environment is windows 7 professional 64 bit, visual studio 2010 and i am working on a windows...

How to execute NUnit test cases from command prompt

How to execute NUnit test cases from command prompt How can I execute a test case from Command Console using NUnit? I had set of Selenium Tests written in C# based on NUnit framework. I need to execut...

18 Jun at 15:23

FluentAssertions: equivalence of sorted lists

FluentAssertions: equivalence of sorted lists I'm trying to establish equivalence of two lists using FluentAssertions in C#, where two things are of importance: 1. the elements are compared by the val...

How to find path of active app.config file?

How to find path of active app.config file? I'm trying to finish this exception handler: ``` if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null) { string pathOfActiveConfigFile = ....

When do I use the TestFixtureSetUp attribute instead of a default constructor?

When do I use the TestFixtureSetUp attribute instead of a default constructor? The NUnit documentation doesn't tell me when to use a method with a `TestFixtureSetup` and when to do the setup in the co...

2 Jul at 17:29

Unit Test Sessions Window Closes when debugging

Unit Test Sessions Window Closes when debugging When I select an NUnit test in the Unit Test Sessions window and click debug, the window disappears. My breakpoints are hit, but if I hit F5, the Unit T...

NUnit - Repeat test case for 3 times, If it fails

NUnit - Repeat test case for 3 times, If it fails I have few test cases for Web Site UI Automation. I want to try my test case at least three times, if it fails for first and second time. That way, I ...

1 Feb at 21:57

NUnit: Dictionary Assert

NUnit: Dictionary Assert I want a , in NUnit, that asserts whether two dictionary are the same. i.e., I want a concise version of the below code: ``` public static void DictionaryAssert(Dictionary dic...

30 Oct at 10:59

Why do we need mocking frameworks?

Why do we need mocking frameworks? I have worked with code which had NUnit test written. But, I have never worked with mocking frameworks. What are they? I understand dependency injection and how it h...

11 Nov at 18:14

CollectionAssert.AreEquivalent with Custom IEqualityComparer

CollectionAssert.AreEquivalent with Custom IEqualityComparer I have two lists, I want to check whether the two lists are the same ( order not important), and whether it's the same depends on the `IEqu...

25 Jul at 04:15

unit testing a unit of work

unit testing a unit of work new to unit testing. I have a unit of work that I am trying to unit test. I am probably missing something simple here. I am trying to unit test the Commit method. I am usin...

14 Jun at 20:56

NUnit TestCaseSource

NUnit TestCaseSource I'm having a go with the TestCaseSource attribute. One problem: when the sourceName string is invalid, the test just gets ignored instead of failing. This would be really bad if t...

9 Apr at 04:20