|
From: <ju...@su...> - 2006-03-18 22:42:06
|
Good one!
Also, Chris Morris can tell you the story about he wrote a framework over
DUnit so we could test WANT by just dropping some files in a folder (or you
could peek into the WANT source code).
Juanca
-----Original Message-----
From: dun...@li...
[mailto:dun...@li...] On Behalf Of Jud Cole
(SOCK Software)
Sent: Saturday, March 18, 2006 5:40 PM
To: dun...@li...
Subject: RE: [DUnit-interest] repeating test cases with different test
setups
Steve,
Maybe it's not quite what you want, but you can definitely create multiple
instances of a test case, we do it here for our 4000+ small test programs
for CodeHealer!
We read them in from a large text file and break them up, and each one can
be enabled / disabled individually.
Here's (the relevant bits of) what we do here, perhaps it will help:
//! Info for a specific test file instance
TTestcaseFile = record
....
end;
//! Delphi source code DUnit test class
TDelphiTestCase = class(TSourceTestCase)
private
//! The parent Delphi suite
FTestCaseSuite: TSourceTestSuite;
published
//! Create the Delphi source code test case
constructor Create(const TestCase: TTestCaseFile); reintroduce;
//! Do the test
procedure DoTheTest; override;
end; // TDelphiTestCase
//! Delphi source code test suite
TDelphiTestSuite = class(TTestSuite)
private
//! The test case suites
FTestCaseSuites: TTestSuite;
protected
//! Add a test
function AddSourceTest(const TestCaseFile: TTestCaseFile):
TSourceTestCase;
//! Build the source code test suite
procedure Build(const Database: string);
end; // TDelphiTestSuite
{!
Create the Delphi source code checker test case.
}
constructor TSourceTestCase.Create(const TestCase: TTestCaseFile); begin
// Create the test indicating the name of the test method
inherited Create('DoTheTest');
// Override the test name
FTestName := Format('%s (%d)', [TestCase.Name, TestCase.DBLine]) end;
{!
Published method called for each test
}
procedure TDelphiTestCase.DoTheTest;
begin
// Parse the individual test program
end;
{!
Add a test.
@param TestCaseFile The test case file to add (has the specific info
for the instance)
@return None
}
function TDelphiTestSuite.AddSourceTest(const TestCaseFile: TTestCaseFile):
TSourceTestCase;
begin
// Create the test
Result := TDelphiTestCase.Create(TestCaseFile);
// Set up any instance specific info
. . .
// Add the test to the suite
FTestCaseSuites.AddTest(Result);
end;
{!
Build the source code test suite.
@param None
@return The test suite
}
procedure TSourceTestSuite.Build(const Database: string); var
Test: TSourceTestCase;
TestCaseFile: TTestCaseFile;
begin
// Iterate through the test case database
FTestCaseDB.IteratorStart;
while FTestCaseDB.IteratorNext(TestCaseFile) do
begin
// Create a test and set it up
Test := AddSourceTest(TestCaseFile);
Test.FTestCaseSuite := Self;
end;
end;
The important bit is the TDelphiTestCase.Create method, where it
1) Sets the name of the published method to list as a test case in the
inherited Create method
2) Sets the test name to SOMETHING UNIQUE in FTestName
This Build method of the test suite loops through the database, and that is
called by the test suite constructor.
I hope that is enough to get you going, I cut out a whole bunch, but
hopefully nothing relevant!
Feel free to ask if you have more questions!
All the best,
Jud
________________________________________
From: dun...@li...
[mailto:dun...@li...] On Behalf Of Krell
Software
Sent: Thursday, March 16, 2006 10:09 PM
To: dun...@li...
Subject: [DUnit-interest] repeating test cases with different test setups
I have test cases which I would like to run under different test setups.
What seemed intuitive to me was to just create the same TTestCase under
different TTestSetups, but I'm running into some problems doing that. If I
have something like this:
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Dunit-interest mailing list
Dun...@li...
https://lists.sourceforge.net/lists/listinfo/dunit-interest
|