nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #01094
[Bug 633884] Re: TestCaseSource does not use Arguments, Categories etc as described in documentation for 2.5.7
Thanks Charlie. I'm running (almost) happily with TestCaseData now.
I say "almost" because I've a use case that doesn't seem to be covered.
I want to be able to pass data _in_ to the test case data generator.
E.g. I'm generating data from a file. I don't want to build the file
name into the data generator.
I can see a possible solution - call the [TextFixtureSetUp] way up
front, before any generation of dynamic tests. At the moment this gets
called _after_ the tests are generated - too late! (I've also tried
[SetUpFixture]/[SetUp] but they seem to get called after the test
generation too.)
Calling it first is not ideal but it allows the name of the file I want
to be used to be used by the generator class. I could do it from a
global class's static property (yuch!).
e.g. Let the generator "know" about the TestFixture class but it could
be any global class.
[TestFixture]
public class TestHarness ....
static string Filename { get; set; } // This holds the name of the
file to be used in generating test data
[TextFixtureSetUp]
public void SetUp()
{
Filename = ... // doesn't work at the moment because the order of execution means this is called too late.
}
[TestCaseData("Generator", "GetData"]
public void ...
...
}
and in the Generator class:
public class Generator
{
public Generator()
{
Filename = TestHarness.Filename; // now it can be used in this class
...
}
public IEnumerable<..> GetData...
{
---------------------------------------------------------------
Thanks again - dynamic tests are really important.
--
TestCaseSource does not use Arguments, Categories etc as described in documentation for 2.5.7
https://bugs.launchpad.net/bugs/633884
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
Status in NUnit V2 Test Framework: Triaged
Bug description:
What happens:
Created a class X that is returned as an IEnumerable<X> in method M of class Z.
This is used in [TestCaseSource(typeof(Z), "M"]
Class X has been given
public string TestName { get; private set; }
public IList<string> Categories { get; private set; }
public bool Ignored;
In the constructor for X, these have been initialised
this.Categories = new List<string> { "foo" };
this.TestName = note;
this.Ignored = true;
The test is executed(contrary to Ignored==true).
There are no categories in the NUinit GUI.
The test is not renamed.
What I expect:
The test is flagged as ignore.
There is a category "foo".
The test is named after the string value in TestName.
NUnit 2.5.7.
Nunit.exe (GUI)
Follow ups
References