Before I get you all confused, let me clarify: I'm NOT asking about running a single test method with different arguments. All clear? Then let's go:
I have a test in Python (Django, but not relevant) that basically...
- starts a http server,
- starts Selenium, opens a web page on this server,
- via Selenium loads and runs a suite of JavaScript tests (via Jasmine)
- collects the results and fails if any test failed
I'd like to make the output of the each Jasmine spec visible as a separate entry in Python unit test output (with its own name)? Extracting it from Javascript via Selenium is the easy part, but I don't know how to connect it with the UnitTest machinery.
Expected code would look something like (pseudocode):
class FooPageTest(TestCase):
def setUp(self):
# start selenium, etc
def run(self, result):
self.run_tests()
for test_name, status, failure_message in self.get_test_results():
if status:
result.add_successful_test(test_name)
else:
result.add_failed_test(test_name, failure_message)
Expected output:
$ python manage.py test FooPageTest -v2
first_external_test ... ok
second_external_test ... ok
third_external_test ... ok
A gotcha: The number and names of test cases would be only known after actually running the tests.
Is it possible to bend unittest2
to my will? How?