docs/workflow/testing/coreclr/test-configuration.md
<CLRTestKind>BuildOnly</CLRTestKind>BuildOnly or BuildAndRun projects with different command line arguments.<CLRTestKind>RunOnly</CLRTestKind><CLRTestKind>BuildAndRun</CLRTestKind><CLRTestKind>SharedLibrary</CLRTestKind>By default (i.e. if not specified explicitly), test "Kind" is BuildAndRun.
Test cases are categorized by priority level. The most important subset should be and is the smallest subset. This subset is called priority 0.
<CLRTestPriority> in the test's project file.
<CLRTestPriority>2</CLRTestPriority> // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
<DefineConstants/><CLRTestTargetUnsupported> property.
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' == 'arm64'">true</CLRTestTargetUnsupported><DisableProjectBuild> property.
<DisableProjectBuild>true</DisableProjectBuild><GCStressIncompatible>true</GCStressIncompatible><HeapVerifyIncompatible>true</HeapVerifyIncompatible><JitOptimizationSensitive>true</JitOptimizationSensitive><NativeAotIncompatible>true</NativeAotIncompatible><IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible><UnloadabilityIncompatible>true</UnloadabilityIncompatible><AlwaysUseCrossGen2>true</AlwaysUseCrossGen2>CrossGenTest is set to false, this test is not run with standard R2R compilation even if running an R2R test pass.
<CrossGenTest>false</CrossGenTest>throw new PlatformNotSupportedException() in its dummy method implementations.[ActiveIssue] attribute if the test fails due to active bug.Use an existing test such as <repo_root>\tests\src\Exceptions\Finalization\Finalizer.csproj as a template and copy it to a new folder under <repo_root>\tests\src.
Be sure that the <AssemblyName> property has been removed
Set the <CLRTestKind>/<CLRTestPriority> properties.
Add source files to the new project.
Add test cases using the Xunit Fact attribute.
We use a source generator to construct the Main entry point for test projects. The source generator will discover all methods marked with Fact and call them from the generated Main.
Alternatively, Main can be user-defined. On success, the test returns 100. Failure can be indicated by any non-100 value.
Example:
static public int Main(string[] notUsed)
{
try
{
// Test scenario here
}
catch (Exception e)
{
Console.WriteLine($"Test Failure: {e}");
return 101;
}
return 100;
}
Add any other projects as a dependency, if needed.
<ProjectReference Include="../ManagedDll.csproj" /><CMakeProjectReference Include="../NativeDll/CMakeLists.txt" />Build the test.
Follow the steps to re-run a failed test to validate the new test.
<repo_root>\src\tests\JIT\Methodical\Methodical_d1.csproj as a template.<NumberOfStripesToUseInStress> to a number such as 10 to make it possible for the test to complete in a reasonable timeframe.Unless tests are manually run on the command line to repro a problem, these parameters are handled internally by the test infrastructure, but for running tests locally, there are a set of standard parameters that these merged test runners support.
[testFilterString] [-stripe <whichStripe> <totalStripes>]
testFilterString is any string other that -stripe. The only filters supported today are the simple form supported in 'dotnet test --filter' (substrings of the test's fully qualified name).
Either the -stripe <whichStripe> <totalStripes> parameter can be used or the TEST_HARNESS_STRIPE_TO_EXECUTE environment variable may be used to control striping. The TEST_HARNESS_STRIPE_TO_EXECUTE environment variable must be set to a string of the form .<whichStripe>.<totalStripes> if it is used. <whichStripe> is a 0 based index into the count of stripes, <totalStripes> is the total number of stripes.