0

According to the fact, what I've got my .NET Standard 2.0 Test Libraries and I want to have a standalone console runner in order to run my tests by anyone from my team and by only using console prompt, I have looked around nunit3-console.exe but I need an option to point him two things: 1) Which DLL to load and run (it's easy already...) 2) Where to look for an appsettings.json

AD 2. I need to pass that to the [SetUp] method, if I would have to do it for a [TestCase()] it should be quite easier... But the question is, how to pass it to the [SetUp]? Cannot find an answer in the internet, maybe I am missing something?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

It's not clear in your question if you are trying to use the NUnit3-console runner or to create your own runner that will run .NET Standard tests. To be clear, nunit3-console does not currently run .NET Core or .NET Standard tests.

Further, your test assemblies must target some platform, not just .NET Standard.

To answer, I'm assuming you know both of the above already. :-)

The NUnit framework supports passing one or more named parameters to a test run. In your tests, you access them as TestContext.Parameters, which returns a TestParameters object supporting a Names property as well as Exists(string name) and several overloads of Get to return parameter values. You can access this in a [SetUp] method if desired.

In order to set the parameters, your runner needs to recognize some argument and pass the information through the TestPackage that is to be executed. You can see code for doing this in both the nunit console runner (which won't work for you) and in nunitlite (which actually would work in your environment).

Charlie
  • 12,928
  • 1
  • 27
  • 31
  • Charlie, I think what you've saved my ass again xd. Now I've got to deal with an `IOException cannot load file or assembly 'System Buffers'`, but I think that means what nunit3-console found my settings file properly and works as desired, but just have something to ... do... And actually those netstandard2.0 libs are targetting both: netstandard and net.framework, in order to make it possible to run them by nunit3-console ;) – Mariusz Budzisz Nov 09 '19 at 17:28