Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet test with TestRunParameters defined should pass parameters to the test runner #860

Closed
livarcocc opened this issue Jun 13, 2017 · 2 comments
Assignees

Comments

@livarcocc
Copy link

From @jhgoodwin on June 13, 2017 20:29

Overview

I am trying to get dotnet test to pass command line parameters into my unit tests so that I can keep from using settings files.

Steps to reproduce

// In the Assembly init test class
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
	Console.WriteLine($"Test Assembly initialized with properties: {string.Join(",", context.Properties.Keys)}");
}

// In the normal Test Class

[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
	Console.WriteLine($"Test class initialized with properties: {string.Join(",", context.Properties.Keys)}");
}
[TestMethod]
public void TestAlwaysErrors()
{
	Assert.IsFalse(true);
}

// Command line to invoke:
dotnet test -v d --diag C:\Temp\testoutput.txt -- TestRunParameters.Foo=Bar

Expected behavior in console

Standard Output Messages:
 Test Assembly initialized with properties: FullyQualifiedTestClassName,TestName,Foo
 Test class initialized with properties: FullyQualifiedTestClassName,TestName,Foo

Actual behavior in console

Standard Output Messages:
 Test Assembly initialized with properties: FullyQualifiedTestClassName,TestName
 Test class initialized with properties: FullyQualifiedTestClassName,TestName

I noticed the diagnostic file in C:\Temp\testoutput.txt mentions the generated runsettings file with the TestRunParameter xml entry plus child entry of Foo, but using procmon it does not seem like this file is passed into the execution in any way.

Am I missing something?

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.3)

Product Information:
 Version:            1.0.3
 Commit SHA-1 hash:  37224c9917

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.3

Copied from original issue: dotnet/cli#6855

@jhgoodwin
Copy link

One other observation, the Foo entry is not getting in the diagnostic testoutput.txt added an a:

<TestRunParameter>
<Parameter Name="Foo" Value="Bar" />
</TestRunParameter>

But instead, I get:

<TestRunParameter>
<Foo>Bar<Foo/>
</TestRunParameter>

Any advice on how to do it differently?

@Faizan2304
Copy link
Contributor

@jhgoodwin : if you will run the command dotnet test -v d --diag C:\Temp\testoutput.txt -- TestRunParameters.Foo=Bar it will update the runsettings with

<TestRunParameters>
<Foo>Bar<Foo/>
</TestRunParameters>

Currently dotnet test doesn't have capability to pass TestRunParameters from command line. It can handle only those settings which is of the form

<RunSettings>
    <node1>
        <node2>
             <node3>value</node3>
        </node2>
    </node1>
</RunSettings>

by running command dotnet test -- node1.node2.node3=value

I have created a separate issue to track this enhancement request. #862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants