|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Calling JUnit Test from GrinderDear Grinder Users,
I am quite new to using JUnit as well as calling JUnit tests from Grinder. Please find below the code that I use to call Junit Test Cases from Grinder,
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from junit.framework import TestSuite
from junit.framework import TestResult
from spdm.escort.specific.test import ComputerBeanTest class TestRunner:
def __call__(self):
# Turn off automatic reporting for the current worker thread.
# Having done this, the script can modify or set the statistics
# before they are sent to the log and the console.
grinder.statistics.delayReports = 1
# Creates a Test Suite.
suite = TestSuite(ComputerBeanTest().getClass());
# Returns the tests as an enumeration.
tests = suite.tests();
# Iterate over the tests.
testNumber = 0
for test in tests:
testNumber += 1
testCase = Test(testNumber, test.getName()).wrap(suite)
testResult = TestResult()
testCase.runTest(test, testResult)
if testResult.errorCount() > 0:
grinder.statistics.forLastTest.success = 0
elif testResult.failureCount() > 0:
grinder.statistics.forLastTest.success = 0
For the above code to run properly should,
public static Test suite() {
return new TestSuite(ComputerBeanTest1.class);
} &
public static void main(String[] args) {
junit.textui.TestRunner.run(suite()); } exist in JUnit Testcase?
If there is no Test Suite() class in Junit test case and the class is called in 'main' funtion directly instead of suite like below:-
public static void main(String[] args) {
junit.textui.TestRunner.run(ComputerBeanTest.class); } I get the below error,
08. 6. 10. 오전 11:48:19 (thread 0 run 0): Aborted run due to Jython exception "TypeError: getName(): expected 1 args; got 0" whilst invoking test runner
TypeError: getName(): expected 1 args; got 0 at line -> suite = TestSuite(ComputerBeanTest().getClass());
The work around would be to add Test Suite Class in JUnit Test Case. But I would like to know if there is a way to fix this using Grinder code? The main objective is to automatically pick all the Junit Test Cases from a folder / drive and add then to Grinder Test Suite, Execute them & Store results for future reference (archive).
Thanks in advance,
Regards,
Dhinakar
------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ grinder-use mailing list grinder-use@... https://lists.sourceforge.net/lists/listinfo/grinder-use |
| Free Forum Powered by Nabble | Forum Help |