nunit-console | NUnit Console runner and test engine | Unit Testing library
kandi X-RAY | nunit-console Summary
kandi X-RAY | nunit-console Summary
NUnit is a unit-testing framework for all .NET languages. Initially ported from JUnit, the current production release, version 3, has been completely rewritten with many new features and support for a wide range of .NET platforms.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nunit-console
nunit-console Key Features
nunit-console Examples and Code Snippets
Community Discussions
Trending Discussions on nunit-console
QUESTION
I have a bunch of testcases within my test-class:
...ANSWER
Answered 2021-May-10 at 12:00A look at the Match method in the source shows: a missing category will de evaluated as false.
So the condition must include a negation. As you already observed, "cat != 'MyCategory'"
will include the tests without category, but will include tests with a category other than 'MyCategory'.
To exclude all tests with any category, you can use the !~
operator (regex non-match), e.g.
QUESTION
I have a Windows Server 2019 that works as a build node for Jenkins. The Windows box does not have a GUI, there is only SSH access that drops into PowerShell Core. The box has been configured with Ansible and all software is installed using Chocolatey.
...ANSWER
Answered 2021-Mar-15 at 12:43That loader loads nunit projects. You want the VSProjectLoader
.
Install with
QUESTION
Within my freestyle Jenkins-job I´m executing unit-tests via the "execute Windows batch-command"-step:
...ANSWER
Answered 2020-Dec-10 at 21:31The plugin set the result to UNSTABLE
because the option, by default, failedTestsFailBuild is set to false
.
You can control the behavior applies of NUnit, setting failedTestsFailBuild
to true
. When you call from a scripted or declarative pipeline.
The issue is the GUI doesn't reflect all the options available for this plugin. There is a PR opened to include this option inside the freestyle pipeline, you can vote up or ask the status of this PR.
To change to an error you need to catch the unstable result and set it to failure using a plugin or a scripted or declarative pipeline.
QUESTION
I have some tests that do some write-operation on a database. I know that´s not really unit-testing, but let´s leave that asside.
In order to enable every test to work on a clean workspace, I rollback all transactions doe so far. However I randomly get concurrency-errors due to database-locks that cannot be established.
This is my code:
Test1.dll
...ANSWER
Answered 2020-Sep-29 at 21:14By default, the NUnit Console will run multiple test assemblies in parallel. Add --agents=1
to force the two assemblies to run sequentially, under a single agent.
Just to clarify some of the other things you tried as well...
[NonParallelizable]
is used to prevent the parallelization of different tests within a single assembly. By default, tests within an assembly do not run in parallel, so adding this attribute when you haven't specifically added [Parallelizable]
at a higher level will have no effect.
[Apartments(Apartment.STA)]
can be added as an assembly-level attribute, and does not have to be added per test, as mentioned in the comments. Check out the docs here: https://docs.nunit.org/articles/nunit/writing-tests/attributes/apartment.html
QUESTION
We have a lot of test in our .NET application. Some of this tests are timing relevant and some code is multi threaded with the .NET TPL. Since several weeks we have a lot of problems with them. Before, the tests are running everytime successful.
I bring an example with a simple timer:
In the class NotSoParallelOps Method ScheduleExecution (L107) a normal System.Threading.Timer
will be started. The corresponding tests are in NotSoParallelOpsTests Method ScheduleExecutionWithStop (L79) where the timer will be started, the test thread is blocked for some time and then it will be evaluated if the timer elapsed.
Another example with the TPL:
...ANSWER
Answered 2020-Sep-18 at 06:57You can give it a try to rewrite your test to use TaskCompletionSource
with CancellationToken
.
If you don't need the EventArgs
then the rewritten version of the test would look like this:
QUESTION
I typically run my unit tests using dotnet test
. The framework I'm using is xunit
. As such, I'm not sure how to run dotMemory unit tests with the CLI.
The documentation recommends:
...ANSWER
Answered 2020-May-12 at 14:28I tried to run tests using latest dotMemory Unit 3.1, it works
dotMemoryUnit.exe "c:\Program Files\dotnet\dotnet.exe" -- test "path\to\the\solution.sln"
For your version it would be
dotMemoryUnit.exe -targetExecutable="c:\Program Files\dotnet\dotnet.exe"
-returnTargetExitCode -- test "E:\MyProject\bin\Release\MainTests.dll"
QUESTION
I am trying to create my own NUnit console runner.
Adding a reference to NUnit
to my project does not let me access NUnit.Common
, NUnit.Engine
or NUnit.Options
as used in the console runner in
https://github.com/nunit/nunit-console/blob/master/src/NUnitConsole/nunit3-console/Program.cs
My Project file:
...ANSWER
Answered 2020-May-01 at 08:49Have a look at project file in GitHub sources, which you've attached. They reference nunit.engine.api
project, so you should add this as well. NUnit.Engine.Api is a Nuget package of this reference
QUESTION
I'm developing some end-to-end tests using C# with .NET Core, Selenium and NUnit.
Now i want to write a login testcase. My tests are started from console simply by using the dotnet test
command.
I simply want to pass username and password to this command and get them in my tests. I can not use NUnit-Console since it doesn't support .NET Core at the moment.
Whats the suggested way to solve this problem? I would prefer to not store the settings in a file but to directly input them into the console.
...ANSWER
Answered 2019-Jan-06 at 18:54Unfortunately, the only way to pass settings from dotnet test
into NUnit is to use a .runsettings
file. There's no way for NUnit to create custom command line arguments for the dotnet test
tool - although we'd love there to be!
Take a look at the sample .runsettings
file here. The specific bit you'll need:
QUESTION
We use NUnit for implementing GUI tests. We have multiple TestFixtures (Test Suites) focused on a set of application functionalities. Test suites have different priorities of execution ( E.g.: Set A need to be verified before running Set B, because Set B uses functionalities from Set A).
My question is: Is there any way how to run test suites in given order using NUnit-Console?
I've tried passing parameter /test for every test suite, parameters were passed in test suite execution priority order, but it didn't work as I expected, test suites weren't executed in required order.
The line was something like that: "[nunit-console runner path]" /test Tests.TestSuiteWithPriority01 /test Tests.TestSuiteWithPriority02 tests.dll
...ANSWER
Answered 2020-Feb-08 at 03:06The --test
command-line option is used to construct a filter, which determines which tests are run. It doesn't affect order - no command-line options have to do with order. NUnit applies the created filter to the tests as it examines them, deciding one test at a time whether it should be executed.
Neither the order of the options nor the order in which NUnit examines the tests has any connection to the order in which they are executed. The execution order is determined by:
- Any
OrderAttributes
you use in your tests. - If no such attributes are used, the order is unspecified. (*)
You can specify [Order(n)]
on any fixture or method. Those items with an OrderAttribute
execute first, starting with the lowest value of n
. If you are running tests in parallel, the order doesn't guarantee that following tests will not start while the first test is running. It's up to you to ensure you don't run such tests in parallel.
See the docs as well: https://github.com/nunit/docs/wiki/Order-Attribute
*Note: some people use the alphabetical order of tests. Some versions of NUnit, in some environments use that ordering. It's not guaranteed by NUnit, so it's not a good idea to rely on it.
QUESTION
I have a nunit3 result file, I need to parse and see if the format is right. I tried with nunit-console, does not have an parser option. How can i do the parse?
...ANSWER
Answered 2020-Jan-16 at 04:43Either use a tool that can parse it or write your own.
A web search for a "NUnit Results Viewer" should give you some choices for existing tools.
You can see the format spec here: https://github.com/nunit/docs/wiki/Test-Result-XML-Format
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nunit-console
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page