Please can someone assist me in how to integrate the XUnit schema to avail of the stopOnFail functionality.
I would like to stop the execution my unit tests if one fails.
By looking at:https://xunit.net/docs/configuration-files
Please correct me where I am wrong but I have:
- Added a new file to the root of my test project: xunit.runner.json
- Updated the .csproj file of my test project to include:
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
- I have added the entire contents of:
https://xunit.net/schema/current/xunit.runner.schema.jsonto my xunit.runner.json and updated the stopOnFail to the following:
"stopOnFail": {
"description": "Enable or disable stopping running further tests once a failed test has been recorded.",
"default": true,
"type": "boolean"
}
This is not working, can someone advise me where I am going wrong please?
You misread the documentation, so let's read it again.
Step 1 states:
That means starting with a
xunit.runner.jsonfile that contains the url to the schema file, not the schema file's contents:The JSON schema for the configuration file isn't a valid configuration file in itself, don't use it like that. The
$schemaproperty is just there so editors know where to look for the schema so they can help you with validation.Then, if you keep reading, you'll see that the
stopOnFailproperty is a boolean with a default value offalse. So, to enable it, you just need to set it totrue. The result is the following configuration file:And then, you have to make sure your runner supports the feature, as it was added in version 2.5.0.