TestSuite.Add() question
Sujin Han <[email protected]> Tue, 29 Jul 2008 16:03:32 -0700 (PDT)
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <[email protected]> |
I have created an extension from ITestCaseBuilder. In BuildFrom method, I instantiate TestSuite and call Add method to dynamically add a bunch of test cases.
In my test module I use a custom attribute to "trigger" the creation of these test cases, which all show correctly when loaded in NUnit.
The problem is that in testresult.xml, all dynamically added methods have the same name! Somehow the names shown in NUnit GUI are ignored when the xml is generated. Is this an expected behavior? Could someone suggest a workaround?
Here's some code snippets:
public NUnit.Core.Test BuildFrom(System.Reflection.MethodInfo method)
{
string parentName = method.DeclaringType.ToString();
TestSuite suite = new TestSuite(parentName, method.Name);
// BUGBUG: nunit test result xml shows identical names
// for all tests that are dynamically added
int counter = 0;
foreach (string atd_filename in this.definitionFiles)
{
object[] args = new object[4];
args[0] = (object)this.workingDir;
args[1] = (object)atd_filename;
args[2] = (object)this.a;
args[3] = (object)this.d;
// Add test cases
suite.Add(new AvtTestMethod(method,
string.Format("Test({0}) {1}", ++counter,
Path.GetFileNameWithoutExtension(atd_filename)),
args));
}
return suite;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/