Merge pull request #9302 from mayankbansal018/dotnetvstestargs
Multiple Logger/TestAdapter inputs from dotnet CLI
This commit is contained in:
commit
7be6af8c3b
2 changed files with 38 additions and 5 deletions
|
@ -40,19 +40,19 @@ namespace Microsoft.DotNet.Cli
|
||||||
Create.Option(
|
Create.Option(
|
||||||
"-a|--test-adapter-path",
|
"-a|--test-adapter-path",
|
||||||
LocalizableStrings.CmdTestAdapterPathDescription,
|
LocalizableStrings.CmdTestAdapterPathDescription,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.OneOrMoreArguments()
|
||||||
.With(name: LocalizableStrings.CmdTestAdapterPath)
|
.With(name: LocalizableStrings.CmdTestAdapterPath)
|
||||||
.ForwardAsSingle(o => $"-property:VSTestTestAdapterPath={o.Arguments.Single()}")),
|
.ForwardAsSingle(o => $"-property:VSTestTestAdapterPath=\"{string.Join(";", o.Arguments)}\"")),
|
||||||
Create.Option(
|
Create.Option(
|
||||||
"-l|--logger",
|
"-l|--logger",
|
||||||
LocalizableStrings.CmdLoggerDescription,
|
LocalizableStrings.CmdLoggerDescription,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.OneOrMoreArguments()
|
||||||
.With(name: LocalizableStrings.CmdLoggerOption)
|
.With(name: LocalizableStrings.CmdLoggerOption)
|
||||||
.ForwardAsSingle(o =>
|
.ForwardAsSingle(o =>
|
||||||
{
|
{
|
||||||
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));
|
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));
|
||||||
|
|
||||||
return $"-property:VSTestLogger={loggersString}";
|
return $"-property:VSTestLogger=\"{loggersString}\"";
|
||||||
})),
|
})),
|
||||||
CommonOptions.ConfigurationOption(),
|
CommonOptions.ConfigurationOption(),
|
||||||
CommonOptions.FrameworkOption(),
|
CommonOptions.FrameworkOption(),
|
||||||
|
|
|
@ -131,6 +131,39 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ItAcceptsMultipleLoggersAsCliArguments()
|
||||||
|
{
|
||||||
|
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||||
|
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("10");
|
||||||
|
|
||||||
|
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD");
|
||||||
|
|
||||||
|
// Delete trxLoggerDirectory if it exist
|
||||||
|
if (Directory.Exists(trxLoggerDirectory))
|
||||||
|
{
|
||||||
|
Directory.Delete(trxLoggerDirectory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call test with logger enable
|
||||||
|
CommandResult result = new DotnetTestCommand()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.ExecuteWithCapturedOutput("--logger \"trx;logfilename=custom.trx\" --logger console;verbosity=normal -- RunConfiguration.ResultsDirectory=" + trxLoggerDirectory);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
var trxFilePath = Path.Combine(trxLoggerDirectory, "custom.trx");
|
||||||
|
Assert.True(File.Exists(trxFilePath));
|
||||||
|
result.StdOut.Should().Contain(trxFilePath);
|
||||||
|
result.StdOut.Should().Contain("Passed VSTestPassTest");
|
||||||
|
result.StdOut.Should().Contain("Failed VSTestFailTest");
|
||||||
|
|
||||||
|
// Cleanup trxLoggerDirectory if it exist
|
||||||
|
if (Directory.Exists(trxLoggerDirectory))
|
||||||
|
{
|
||||||
|
Directory.Delete(trxLoggerDirectory, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
|
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue