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

I am trying to access Author attribute along with TestCaseSource attribute, but unable to retrieve value of author assigned to Test #3428

Open
SeleniumMerlinNet opened this issue Nov 18, 2019 · 1 comment

Comments

@SeleniumMerlinNet
Copy link

SeleniumMerlinNet commented Nov 18, 2019

While trying to access Author value in TearDown i am getting null value. Do let me know if Property attribute works with TestCaseSource Attribute.
Please find below code:

[TestCaseSource(typeof(TestDataMerlin), "LoginDetails", new object[] { new string[] { "TC01"} }),Author("Kalyani"),Description("Hi")]

public void PatientEnrollment(string userDetails, LoginDetails loginDetails)
{
try
{
}
}
[TearDown]

public void TestCleanup()
{
var testCategory = TestContext.CurrentContext.Test.Properties["Author"];
}
@CharliePoole
Copy link
Contributor

When you use the attributes on a method with parameters, a property is created on the Test suite, which contains all the individual cases. It was probably a design flaw to do it this way because there is no way for you to easily access those properties. All your test code executes in the context of the individual test case, not the containing suite.

You can, of course, set properties on the individual TestCaseData items returned by your TestCaseSource. It would be a significant but not too difficult change in NUnit to make all property attributes apply to the individual test cases in this situation. Whether it's a breaking change, which must wait until NUnit 4, is a matter for the team to decide.

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

2 participants