49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
use import="Json"
|
|
use import="Environment"
|
|
|
|
default NO_PARALLEL_TEST_PROJECTS='${E("NO_PARALLEL_TEST_PROJECTS")}'
|
|
|
|
@{/*
|
|
|
|
dotnet-test
|
|
Run unit tests in your project.
|
|
|
|
projectFile=''
|
|
Required. Path to the test project.json to execute
|
|
|
|
configuration=''
|
|
Optional. The configuration to build in. Defaults to 'Debug'.
|
|
*/}
|
|
|
|
default configuration = 'Debug'
|
|
|
|
@{
|
|
var projectText = File.ReadAllText(projectFile);
|
|
var project = (JsonObject)Json.Deserialize(projectText);
|
|
|
|
// This check is just used to transition from dnx to dotnet
|
|
var commands = project.ValueAsJsonObject("commands");
|
|
|
|
if (commands == null && project.Keys.Contains("testRunner"))
|
|
{
|
|
var projectFolder = Path.GetDirectoryName(projectFile);
|
|
var projectName = Path.GetFileName(projectFolder);
|
|
|
|
var testArgs = "--configuration " + configuration;
|
|
|
|
var configs = project.ValueAsJsonObject("frameworks");
|
|
IEnumerable<string> targetFrameworks = configs == null?
|
|
new string[0]:
|
|
configs.Keys.Where(k => k.StartsWith("dnx", StringComparison.OrdinalIgnoreCase));
|
|
|
|
foreach (var framework in targetFrameworks)
|
|
{
|
|
if (framework.StartsWith("dnxcore"))
|
|
{
|
|
Dotnet("test " + testArgs, projectFolder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|