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.

0
votes
0answers
12 views

How to mock a OPC UA Session for unit testing in C#

I have a C# application, which includes a service that works with multiple OPC UA Sessions (UnifiedAutomation.UaClient.Session). These sessions are created by connecting to addresses like opc.tcp://...
0
votes
2answers
21 views

NUnit Integration Tests on Web API - how to create/destroy integration test db

I'm implementing NUnit Integration Tests of our controller REST endpoints in a .NET Web API 2 project. We use an Entity Framework code-first from database approach to create our controllers and models....
2
votes
1answer
15 views

Breakpoint does not hit in Nunit Unit Tests

I am facing some kind of weird visual studio behavior I guess... I have done Unit Testing in my application using NUnit, in some Unit Tests I have used NFluent and NSubstitute (to make my UT more ...
-1
votes
0answers
23 views

NUnit3 keyword driven framework

I am developing framework where I want to get keyword from excel file and execute method in c# with selenium. Here is my code structure: [TestFixture] class Program { Core core; [...
0
votes
0answers
14 views

Gettting No test is available in myspedflowTest.dll.Using NUNIT 3.11.0 and Nunit3TestAdapter

I am having a .net core project which keep throwing error. No test is available in ./././myspedflowTest.dll. Make sure that test discoverer & executors are registered and platform & framework ...
0
votes
0answers
11 views

NUniteLite 3.11.0 throwing Null Reference Exception with AutoRun in LINQpad

The following LINQPad query throws NullReferenceException in the try-catch block: void Main() { var specialFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var ...
0
votes
2answers
27 views

C# Nuget or AutoCode Generator to Compare Multiple Objects in Unit Testing

The following test creates error when I test tuples. 'Assert.AreEqual(test,productRepository.GetById(1))' threw an exception of type 'NUnit.Framework.AssertionException' Many solutions presented ...
0
votes
2answers
41 views

NUnit - TestContext.CurrentContext.Result.Outcome.Status Always Inconclusive

I've noticed that NUnit's TestContext.CurrentContext.Result.Outcome.Status is always Inconclusive at the end of a test run. The CurrentContext is also unaware that any assertions have taken place. ...
1
vote
2answers
46 views

C# Nunit and Running same database populate everytime before test

I have an Entity Framework DB Context file. How would I setup the DBContext, and run SetUp everytime (to have clean populated database) before running a test? It cannot see the dbcontext in the NUnit ...
0
votes
1answer
23 views

How to validate varied options via SWITCH based on user type in Selenium(C#)

I am using - Selenium(C#) on NUnit framework and I am trying to validate a condition in my test that presents the user with varied options based on the user who has logged in(as explained below) - ...
0
votes
2answers
43 views

C# Comparing Multiple Objects in Unit Testing without Overriding

The following test creates error when I test tuples. 'Assert.AreEqual(test,productRepository.GetById(1))' threw an exception of type 'NUnit.Framework.AssertionException' 1) How would I resolve this ...
1
vote
1answer
23 views

Structure of Keyword Driven framework in NUnit

I am trying to build simple keyword driven framework in NUnit with selenium. The problem is I can't find the way to build it since NUnit runs every method lying under [Test] attribute. Example: Core ...
0
votes
2answers
21 views

IHeadersDictionary returning null after mocking

I am trying to mock IHeadersDictionary and whenever I try to access it I returns Null. public interface IRequestScopeContext { IHeaderDictionary Headers { get; set; } ISessionInfo ...
0
votes
1answer
78 views

How to write a test case for abstract class method

Here is my code, I want to write a unit test for Build method as part of writing a test case for class D. public class X { } public interface IB { X GetX(X value); } public class B : IB { ...
0
votes
3answers
48 views

How to Create a Unit Test for Adding Items in a Repository?

I have an IUnitOfWork interface that encapsulates my custom repositories. My custom repositories in turn inherit from an IRepository interface. // The class that I am attempting to unit test // ...
-1
votes
0answers
13 views

Unit Tests of method in viewmodel with DataRowView implementation MVVM?

I am loading data into datagrid dynamically using sql query via ADO .Net. The selected item is of type DataRowView. I am fetching the required data from DataRowView based on the type of table in sql ...
0
votes
2answers
19 views

How to set the result folder using command line parameter to nunit-console?

I am trying to run NUnit tests from command line and trying to save the results under TestResults folder. I have tried using following commands, but nothing has created the test results under intended ...
0
votes
0answers
26 views

Rerunning Test Results (trx) file produced by VSTS

Out NUnit based Tests solution is executed by VSTS which produces a trx file at the end of the run. The file opens without issues in Test Results window my Visual Studio (2017) while the solution is ...
0
votes
1answer
46 views

C# NUnit and testing tuples

The following test creates error when I test tuples. 'Assert.AreEqual(test,productRepository.GetById(1))' threw an exception of type 'NUnit.Framework.AssertionException' How would I resolve this? ...
1
vote
1answer
42 views

What is the difference between TypeOf and InstanceOf in NUnit?

In NUnit, what is the difference between Is.TypeOf and Is.InstanceOf? In the following example, I've notice that they are both return true: public class Foo { public Boo GetBoo() { ...
-2
votes
1answer
37 views

C# get private method by reflection from another class and invoke it [duplicate]

In Java you can invoke a private method like so: Method m = obj.getClass().getDeclaredMethod("foo", null); m.setAccessible(true); m.invoke("bar"); What is the equivalence in C#? I need to call a ...
0
votes
3answers
31 views

How to save NUnit test results to xml?

I am trying to learn Selenium in C# and everything is going smooth so far. But I wanted to export reports to xml. Looked over some answers but did not find any exact answer. Seems like it is done with ...
0
votes
0answers
27 views

Catching exceptions within NUnit SetUp call

I want to create a flexible wrapper to log test fails. Let;s suppose I have a class: internal class LogMethodCommand : DelegatingTestCommand { public LogMethodCommand(TestCommand innerCommand) ...
0
votes
0answers
15 views

How can I get output to 'stream' its output in the Resharper unit test session viewer instead of dumping it at the end of the test?

I'm using Visual Studio 2015 (14.0.25431.01 Update 3) Resharper Ultimate 2018.2.3 (build 2018-09-12) Windows 10 x64 v1803 .NET Framework 4.5.2 What I want is to be able to run a unit test in the ...
1
vote
2answers
37 views

Does .NET Core work with NUNIT console runner?

I have a very simple test! [Test] public void TestMethod1() { Assert.IsTrue(false); } When I try to run this with nunit3-console.exe I get the following error. NUnit.Engine....
0
votes
0answers
30 views

Mock DBContext class which uses a stored procedure and SqlAdapter to fetch details using Nunit and Moq

I need to Mock a DBContext class which in turn uses a Stored procedure & SqlAdapter to fetch result using Nunit and Moq . There is Unity Resolver IOC involved which takes care of DI . ---Web ...
0
votes
1answer
28 views

Data type for DbContextOptionsBuilder in NUnit

I am trying to locate the data type for DbContextOptionsBuilder. I have an Entity Framework DBContext file. I setup an InMemory database with NUnit. How can I set this up without var? I know its ...
0
votes
1answer
39 views

Moq and setting up DB Context

I have an Entity Framework DB Context file. I am trying to setup a Moq framework in NUnit. Currently receiving error below for Moq Nunit test. How would I setup the DBContext, and add items to a ...
0
votes
1answer
50 views

Mock `printfn` in F# tests

I'm trying to write a test for a small lib I'm writing that (essentially) just logs to the console. Is there a way to mock function like this is F#? example: in src/Lib/Lib.fs module Lib let print ...
0
votes
0answers
24 views

Is it okay to reference existing repository class in Test classes

I am new to unit test, I have created one unit test to test EF Add operation. I am using existing repository class which has a AddTransaction method. It is using EF to insert the record into sql ...
0
votes
2answers
33 views

Reboot computer during automation testing

I'm using SpecFlow with NUnit. Some scenarios require reboot computer in the middle of their running. I did not find any approaches to do it for specified technologies. Is there someone who can help ...
0
votes
1answer
11 views

Setting output file for tests with SetUp method

Hello i have a class full of testcase-s.I want to pre-set each testcase output file depending on his identifier or name. class SetTests { [SetUp] public async Task WriteHeader() { ...
1
vote
1answer
25 views

NUnit: How can I set name of test depending on parametr in [TestFixture(typeof(param))]

I'm using NUnit + Webdriver + C#. Setup class has next stucture: [TestFixture(typeof(InternetExplorerDriver))] [TestFixture(typeof(ChromeDriver))] public partial class SetupBase<TWebDriver> ...
0
votes
0answers
32 views

InitializeComponent() for Visual Studio DialogWindow throws exception in Nunit test

I am developing an extension for Visual Studio that uses DialogWindow from the Microsoft.VisualStudio.PlatformUI namespace. My window looks something along the lines of this: ... using Microsoft....
0
votes
2answers
40 views

NUnit runner compilation failed error with ReSharper

I am not able to run tests in ReSharper 2018.2.3 after update ReScharper it self and Visual Studio till 15.8.6. Reinstall does not help. ERROR JetBrains.ReSharper.UnitTestRunner.nUnit.CodeDom....
0
votes
1answer
29 views

how to specify the platform (android or ios) test with nunit console

I have a xamarin ui test multiplateform project, I would like to know if I launch my test via the console it is possible to launch only ios or android tests. For if it launches the two ... my current ...
-1
votes
1answer
37 views

Trying to create Mock Object for DiscordSocketClient and its properties

I am working on a discord bot project written in c# and currently trying to implement unit tests for the system using NUnit and Moq. For one of the features I need to access the server roles, which is ...
1
vote
1answer
27 views

Resharper does not discover my NUnit tests in a UWP UnitTestProject

using Visual studio 2017 community 15.6.4 Resharper 2018.2 with dotcover 2018.2.3 What I did : Create a Universal Window UnitTestProject App. Reference in there, via nuget, the following packages : ...
0
votes
0answers
21 views

Nunit, output all assert statements

I am doing some unit test using NUNIT Here is an sample, this is not a real test. public void TestSomething() { string A ='A'; string B ='A'; string F ='F'; ...
1
vote
0answers
30 views

Visual Studio NUnit adapter only run 10K tests at a time

I am using VS 2017 with NUnit 3.10. I have a solution that has ~50K unit tests. The registered test time in the explorer window is 5-10 minutes (most of the tests take less than a millisecond). ...
0
votes
1answer
25 views

NUnit custom Command not calling into Execute()

I have created a custom NUnit attribute based on this blog post (with but a few minor tweaks) which basically just returns a custom command. The command derives from DelegatingTestCommand and ...
0
votes
1answer
27 views

NUnit tests refusing to run due to StackOverflowException

I'm not sure what is causing the exception here at all. I had a number of tests which make use of NUnit TestCases, and these tests were all running fine with no issues. I then wrote an additional ...
1
vote
1answer
18 views

How to use ITestEventListener in Nunit 3 in Visual Studio 2017

The steps I have taken: I have created a separate project for the ITestEventListener Installed Nunit.Engine.Api v3.9.0 for the new project The class A that implements ITestEventListener has the [...
0
votes
1answer
16 views

Jira Ticket reference in Nunit header

We are creating Nunit tests which have corresponding Jira stories. We have been putting the ticket reference in the test name, but is there a convention or Nunit attribute that we should consider ...
0
votes
1answer
19 views

NUnit - Is there a way to find out which test case is being ran at a point in time?

In an attempt to reduce the amount of tests I have within a single class I am using NUnits TestCase attribute to feed a number of testcases into a single test method. However the output of each of ...
0
votes
1answer
26 views

NUnit TestRunner working directory is different depending on target framework of project

I am developing a library which has a test project in the solution. The library uses several framework from the .NET universe (like net462 or netcoreapp2.0) and works fine. The test project currently ...
0
votes
1answer
20 views

NUnit3.testadapter is included in code coverage

I faced a problem in Azure DevOps today. I'm trying to set up a test execution pipeline with code coverage enabled and everything works fine except one particular thing related to NUnit. When I run ...
-2
votes
0answers
40 views

How to get consolidated code coverage for .net core and .net framework test projects in TeamCity

Now we have two separate projects in TeamCity: one for .net core tests (running via DOT CLI runner), and another - for .net framework tests (running NUnit 3 runner). Each of them uses JetBrains ...
0
votes
1answer
33 views

unit testing umbraco 7.12 controller

i've setup a unit test project for my umbraco 7.12 installation with Our.Umbraco.Community.Tests nuget installed as well as nunit, nunit 3 test adapter and NUnitV2Driver. i have a unit test where i'm ...
0
votes
1answer
27 views

Get tests to be executed in [SetUpFixture] while running via nunit3-console.exe

I'm using NUnit.ConsoleRunner.3.8.0 to run NUnit 3.10.1 tests. The problem is: if there is specific tests in run filter, I should properly configure my SUT. It is quite painful process, so I would ...