Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting random seed for a test case #843

Closed
codito opened this issue Apr 9, 2021 · 3 comments
Closed

Reporting random seed for a test case #843

codito opened this issue Apr 9, 2021 · 3 comments
Assignees
Milestone

Comments

@codito
Copy link

codito commented Apr 9, 2021

Scenario

For the test case below, the nunit console runner produces a xml output with the seed value to enable repro. We'd like to support this behavior in the nunitxml.testlogger for dotnet test. This information is not available today in the TestPlatform object model (TestCase or TestResult) data.

Ask

Would it be possible/desirable for the adapter to expose the seed value as an additional data on the TestCase? May be as a custom property (TestCase.SetPropertyValue); similar mechanism is already used for test category.

Repro

	[TestFixture]
	public class RandomizerTests
	{
		[Test]
		public void Sort_RandomData_IsSorted()
		{
			var random = TestContext.CurrentContext.Random;
			var data = Enumerable.Range(0, 2).Select(i => random.Next()).ToArray();

			Array.Sort(data);

			Assert.That(data, Is.Ordered);
		}
	}

Additional Information

  • NUnit and NUnit3TestAdapter versions: 3.13.1, 4.0.0-beta.2
  • Visual Studio edition and full version number (see Help About) - NA. Trying with dotnet test
  • A short repro, preferably attached or pointing to a git repo or gist. See above
  • What .net platform and version is being targeted: .netcoreapp 3.1
  • If TFS/VSTS issue, what version, hosted, on-premises, and what build task you see this in: NA
@OsirisTerje
Copy link
Member

@codito Please check if the enclosed dev package of the adapter solves the issue for you. The Seed value is added to both the test case and the test result. If you set the NUnit.Verbosity=5, it will also be output to the console.
NUnit3TestAdapter.4.0.0-dev.570.zip

@OsirisTerje OsirisTerje added this to the 4.0 milestone May 24, 2021
OsirisTerje added a commit that referenced this issue May 24, 2021
@codito
Copy link
Author

codito commented May 25, 2021

@OsirisTerje thank you! I can confirm the fix is working great. Will look forward to the availability of next prerelease in nuget.

@OsirisTerje
Copy link
Member

Thanks! It will be part of the proper 4.0 release, early next week. You can grab it off the myget feed once I have the PR merged until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants