A set of test options, which can be included in the source text of tests using special comments like // @ReportOutputWarnings
.
This class is JSON-serializable. Another way to define options is to add a file named metalamaTests.json
into the test directory or
any parent directory.
Namespace: Metalama.Testing.AspectTesting
Assembly: Metalama.Testing.AspectTesting.dll
Syntax
[JsonObject]
public class TestOptions
Constructors
Name | Description |
---|---|
TestOptions() |
Properties
Name | Description |
---|---|
AcceptInvalidInput | Gets or sets a value indicating whether the test should be executed even if the input compilation has errors.
To enable this option in a test, add this comment to your test file: |
AddHtmlTitles | Gets or sets a value indicating whether titles (tooltips) should be added to HTML files.
To enable this option in a test, add this comment to your test file: |
AllowCompileTimeDynamicCode | Gets or sets a value indicating whether the test is allowed to have compile-time code that has dynamic calls.
To enable this option in a test, add this comment to your test file: |
AppliedCodeFixIndex | Gets or sets the zero-based index of the code fix to be applied
when TestScenario is set to CodeFix or CodeFixPreview.
To set this option in a test, add this comment to your test file: |
CheckMemoryLeaks | Gets or sets a value indicating whether memory leaks should be detected. This features is supported from .NET 6. Leaks are detected
by trying to unload the |
ClearIgnoredDiagnostics | Gets or sets a value indicating whether the list of IgnoredDiagnostics inherited from the parent level (directory or base directory)
must be cleared before new diagnostics are added to this list. This option is not inherited from the base level.
To enable this option in a test, add this comment to your test file: |
CompareProgramOutput | Gets or sets a value indicating whether the program output should be compared to its expected value. The default value is |
CompareWhitespace | Gets or sets a value indicating whether whitespace are taken into account while comparing the the expected output |
DefinedConstants | Gets the set of preprocessor symbols that are defined for this test.
To add an item into this collection from a test, add this comment to your test file: |
DependencyDefinedConstants | Gets the set of preprocessor symbols that are defined for this test dependency.
To add an item into this collection from a test, add this comment to your test file: |
DependencyLanguageVersion | Gets or sets the version of the C# language that the dependencies of the test should be compiled with.
To set this option in a test, add this comment to your test file: |
DependencyLicenseKey | Gets or sets the name of the license key used to compile the test dependency. The LicenseKeyProviderType property must be specified.
To set this option in a test, add this comment to your test file: |
EnableLogging | Gets or sets a value indicating whether Metalama should produce logs and output them to the Xunit test log.
To enable this option in a test, add this comment to your test file: |
ExcludeAssemblyAttributes | Gets or sets a value indicating that assembly-wide attributes should not be added to the test output.
The default value is |
ExecuteProgram | Gets or sets a value indicating whether the |
ExpectedEndOfLine | Gets or sets a value indicating which end-of-line sequence is expected.
To set this option in a test, add this comment to your test file: |
ExpectedException | Gets or sets the fully qualified name of expected exception type to be thrown.
To set this option in a test, add this comment to your test file: |
ForbiddenConstants | Gets the set of preprocessor symbols that are forbidden for this test, test would be skipped if any is present.
To add an item into this collection from a test, add this comment to your test file: |
FormatCompileTimeCode | Gets or sets a value indicating whether code of the compile-time project should be formatted.
The default value is |
FormatOutput | Gets or sets a value indicating whether the output |
IgnoreUserProfileLicenses | Gets or sets a value indicating whether the licenses registered in the user profile should be ignored.
The default value is |
IgnoredDiagnostics | Gets a list of warnings that are not reported even if ReportOutputWarnings is set to |
IncludeAllSeverities | Gets or sets a value indicating whether diagnostics of all severities should be included in the rest result. By default, only
warnings and errors are included.
To enable this option in a test, add this comment to your test file: |
IncludeDeclarationInDiagnosticReport | |
IncludeLineNumberInDiagnosticReport | Gets or sets a value indicating whether the line number should be included in reports of warnings or errors in the consolidated test output.
The default value is |
IncludedFiles | Gets the list of source code files that should be included in the compilation.
To enable this option in a test, add this comment to your test file: |
InvalidSourceOptions | |
IsSkipped | Gets a value indicating whether the current test must be skipped. |
KeepDisabledCode | Gets or sets a value indicating whether disabled code should be kept as trivia.
To set this option in a test, add this comment to your test file: |
LanguageFeatures | Gets or sets the list of C# language features that the test should be compiled with.
To set this option in a test, add this comment to your test file: |
LanguageVersion | Gets or sets the version of the C# language that the test should be compiled with.
To set this option in a test, add this comment to your test file: |
LaunchDebugger | Gets or sets a value indicating whether the JIT debugger should be launched before executing the test.
The default value is |
LicenseKey | Gets or sets the name of the license key used to compile the test input. The LicenseKeyProviderType property must be specified.
To set this option in a test, add this comment to your test file: |
LicenseKeyProviderType | Gets or sets the name of the type implementing the ILicenseKeyProvider. This property is required when LicenseKey or DependencyLicenseKey is specified. |
MainMethod | Gets or sets the name of the |
NullabilityDisabled | Gets or sets a value indicating whether C# nullability is disabled for the compilation.
To enable this option in a test, add this comment to your test file: |
OutputAssemblyType | Gets or sets a value indicating which type of the output assembly should be used for the test. Currently valid values are |
OutputCompilationDisabled | Gets or sets a value indicating whether the output file must be compiled into a binary (e.g. emitted).
To enable this option in a test, add this comment to your test file: |
PreserveWhitespace | |
ProjectName | Gets or sets the project of the test. By default, the test file name without extension is used. |
RandomSeed | Gets or sets the seed for the random number generator. The default value is random when Repeat is |
References | Gets the list of assembly names that should be included in the compilation.
To add a named assembly reference, add this comment to your test file: |
RemoveDiagnosticMessage | Gets or sets a value indicating that the test output should not include the diagnostic message, but only the diagnostic ID.
The default value is |
RemoveOutputCode | Gets or sets a value indicating that the test output should not include the transformed code, but only the diagnostics.
The default value is |
Repeat | Gets or sets the number of times the test must be repeated. This can be used to reproduce random issues.
The default value is |
ReportErrorMessage | Gets or sets a value indicating whether the ErrorMessage should be added to
the test output.
You can only define this option in the |
ReportOutputWarnings | Gets or sets a value indicating whether the diagnostics of the compilation of the transformed target code should be included in the test result.
This is useful when diagnostic suppression is being tested.
To enable this option in a test, add this comment to your test file: |
RequireOrderedAspects | Gets or sets a value indicating whether an error should be reported if the compilation uses aspects that
are not explicitly ordered.
To enable this option in a test, add this comment to your test file: |
RequiredConstants | Gets the set of preprocessor symbols that are required for this test, otherwise the test would be skipped.
To add an item into this collection from a test, add this comment to your test file: |
SkipAddingSystemFiles | Gets or sets a value indicating whether adding system files to the test compilation should be skipped.
Namely, there is one file that adds the |
SkipReason | Gets or sets the reason for which the test must be skipped, or |
TargetSyntaxTreeSuffix | Gets or sets a value indicating the target syntax tree suffix. This allows the selection of a different syntax tree for the test scenario. This is currently valid only for Preview scenario. |
TestRunnerFactoryType | Gets or sets the name of the test runner factory type (implementing ITestRunnerFactory).
You can only define this option in the |
TestScenario | Gets or sets a value indicating the test scenario. See TestScenario enum values for details. |
TestUnformattedOutput | |
WriteInputHtml | Gets or sets a value indicating whether HTML of syntax-highlighted files should be produced for input files. If |
WriteOutputHtml | Gets or sets a value indicating whether HTML of syntax-highlighted files should be produced for the consolidated output file. If |