Is there any way to get testResult of the test at the end of test script itself.

Asked by nirmesh patel

We are writing our test using SST and I want to get the result of the test at the end of test script to report it to external test mgmt system. I want to call this external API to record this result by passing test result as an argument to it. I know that we can do this in unittest like this"

Example:
suite = unittest.TestSuite()
suite.addTest(TC0002TestFxSwap('test_c0002testfxswap__1311'))
testResult = unittest.TextTestRunner(verbosity=2).run(suite)

Is there any way of this in SST?

Question information

Language:
English Edit question
Status:
Answered
For:
selenium-simple-test Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Corey Goldberg (coreygoldberg) said :
#1

hi.

have you looked at using xml output reports (-r option)?
you can call sst-run with the -r option to change report output from console to xml or html.

example:

$./sst-run -r xml mytests

this will create `results/results.xml`, containing an xml output report of your last test run. It's written by the junitxml module and is formatted in JUnit's results format. This is what I am using to consume results from a CI system (Jenkins).

as to how SST calls unittest internally, look at the logic inside `src/sst/runtests.py` around line 100, inside the `runtests()` function.
In console mode, it does:

runner = TextTestRunner(verbosity=2)
runner.run(alltests)

we could change `runtests` function to return test_result like in your example. would that be helpful?

hth,

-Corey

Revision history for this message
nirmesh patel (nirmeshptl) said :
#2

I am trying to get this test result and send it to SpiraTest by calling spiratest web service to update the test case result in spiratest.

>>we could change `runtests` function to return test_result like in your example. would that be

Yes above solution should work for me if this return value is accessible within test script.

Revision history for this message
Corey Goldberg (coreygoldberg) said :
#3

> Yes above solution should work for me if this return value is accessible within test script.

ah.. I was thinking at the test runner level, not within your scripts.

you might be able to use the existing run_test() function in the actions API:
http://testutils.org/sst/actions.html#run-test

consider this example...

I have a script named `mytest.py` containing an SST test case:

----------------
from sst.actions import *

# do some test stuff
RESULT = 'hello'
----------------

then I have a script named named `calltests.py` that runs the [sub]test:

----------------
from sst.actions import *

result = run_test('mytest') # this will the be the string "hello"
foo = do_something_with_result(result) # implement this
send_to_spiratest(foo) # implement this
----------------

you can then invoke `sst-run calltests` from the command line, which would run `mytest.py` and do something with RESULT.

hth,

-Corey

Can you help with this problem?

Provide an answer of your own, or ask nirmesh patel for more information if necessary.

To post a message you must log in.