question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuring maximum number of tests has no effect in .NET Core

See original GitHub issue

Here’s test pasted from https://fscheck.github.io/FsCheck/RunningTests.html

[Property]
public void Test()
{
	var configuration = Configuration.Quick;
	configuration.MaxNbOfTest = 1000;
	configuration.QuietOnSuccess = true;
	true.ToProperty().Check(configuration);	
}

I’m changing the number assigned to MaxNbOfTest and the flag to true/false, but the test runner always displays Ok, passed 100 tests. The application is targeting .NET Core 2.0:

<TargetFramework>netcoreapp2.0</TargetFramework>
//..
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="FsCheck" Version="2.10.6" />
<PackageReference Include="FsCheck.Xunit" Version="2.10.6" />

I was thinking runner itself has something to do with this, but both Resharper and Visual Studio Test Runner in my VS2017 provide same output.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtschelfthoutcommented, Jan 8, 2018

Like @ploeh said - that snippet is under the heading “Running a single property from an fsx/csx file or a command line runner”. What is happening is that you are running 100 times 1000 tests. The test method is interpreted as an Fscheck test with default config (there are properties on the PropertyAttribute to change these). Then, the inner test is true.ToProperty().Check which is executed 1000 times but doesn’t print anything on exit as per your config.

See here for xUnit.net examples: https://fscheck.github.io/FsCheck/RunningTests.html#Using-FsCheck-Xunit

EDIT: I noticed there are no C# examples there, here’s one that’s trivial and equivalent to the stand-alone snippet:

[Property(QuietOnSuccess = true, MaxNbOfTests=1000)]
public bool Test() => true

// this one will fail
[Property(QuietOnSuccess = true, MaxNbOfTests=1000)]
public bool Test(int i) => i > 0

1reaction
ploehcommented, Jan 8, 2018

In a unit test, you either need QuickCheckThrowOnFailure as described in https://fscheck.github.io/FsCheck/RunningTests.html, or, if you’re using FsCheck.XUnit, you must return the Property.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't read app.config in C# .NET Core unit test project with ...
The console app reads the app.config fine, but the unit test method fails and I cannot figure out why. Both are using a...
Read more >
Threading config settings - .NET
Learn about the settings that configure threading for .NET Core ... Specifies the maximum number of threads for the worker thread pool.
Read more >
Configure unit tests by using a .runsettings file
This setting determines the maximum number of test DLLs, or other test containers that can run in parallel. Each DLL runs in its...
Read more >
Unit Tests with Code Coverage No Longer Able to Run in ...
For the past few years, we've been running unit tests with code coverage in parallel using a custom local.testsettings file. With the release...
Read more >
Boosting ASP NET Core application performance
In this article we will consider performance advice, which aims to boost entire application performance with maximum effect while minimizing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found