← Back to team overview

nunit-core team mailing list archive

[Bug 633884] Re: TestCaseSource does not use Arguments, Categories etc as described in documentation for 2.5.7

 

I've got something working using TestCaseData.  It does seem to cut out
a step.  However it means a long signature for the test.

		[TestCaseSource(typeof(SimTestDataGenerator), "TestArguments")]
		public void IndividualTestCasesShouldBeGenerated(bool ignored, IList<string> categories, string note,
			string simFile, bool update, RunLocation runLocation, ThreadMode threadMode, ShockFileAction shockFileAction,
			string baselineCulture, string versionUnderTestCulture)

I think I may see your point now if I use TestCaseData to return an
instance of a class that describes the data.  Perhaps something along
the lines of:

		[TestCaseSource(typeof(SimTestDataGenerator), "TestArguments")]
		public void IndividualTestCasesShouldBeGenerated(SimTestDescriptor descriptor)
		{
...
and

		public IEnumerable TestArguments()
		{
			foreach (SimTestFileDescription line in this.Descriptions)
			{
				if (!line.Ignore)
				{
					yield return new TestCaseData(new SimTestDescriptor(line.Category, line.Note, line.SimFile, line.Update,
					                                GetEnum<RunLocation>("RunLocation", line.RunLocation),
									GetEnum<ThreadMode>("ThreadMode", line.ThreadMode),
									GetEnum<ShockFileAction>("ShockFileAction", line.ShockFileAction),
									line.BaselineCulture, line.VersionUnderTestCulture))
													   .SetCategory(line.Category)
													   .SetName(line.Note)
													   .SetDescription(line.Note);
				}
			}
		}

-- 
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)





References