Some script is not getting executed when using HTMLTestRunner.

Asked by nupur

import unittest
import HTMLTestRunner

class BDTests(unittest.TestCase):
    def setUp(self):
        App.open("C:\\Program Files\\Internet Explorer\\iexplore.exe www.proofguru.com")
        wait("EmailID.png") # wait until the app appears

    def testA(self):
        click("lIIIGIIIl.png")
        type("emailid")
        type("password")
        click("1342006035181.png")
        wait("Home-1.png")
        print("pass")

suite = unittest.TestLoader().loadTestsFromTestCase(BDTests)
outfile = open("C:\\Sikuli\\Reports\\loginpass.html", "w")
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title='Login_Pass Report', description='Login' )
runner.run(suite)

My problem is that whatever i am writing below click("1342006035181.png") statement in testA function is not getting executed and its working fine when replacing last 3 lines with "unittest.TextTestRunner(verbosity=2).run(suite)" statement.

what may be the issue??
Please help.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- general comment:
tests in unit test environment should always be terminated with an assert, since these assertion exceptions are catches by the test runner, to produce the testing statistics.

your case:

instead of:

       wait("Home-1.png")
        print("pass")

use:

    assert exists("Home-1.png", 10) # add sufficient waiting time

--- whatever i am writing below click("1342006035181.png") statement in testA function is not getting executed
- the whole function does not execute?
- or it does not execute past the click statement?

-- whatever i am writing
what happens if
print("I am after the click")
is the only statement after the click?

Revision history for this message
nupur (nupur) said :
#2

It does not execute past the click statement.
But in HTML report, its showing the print statement. I dont know whether its the functionality or an issue??

If print is the only statement after click statement thats not printing in result area but in report its coming.
Shdn't it come in result area also??
I'm Confused.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

-- since the print statement is executed (wherever the output might go), your script is executed past the click statement.

-- the HTMLTestrunner seems to catch the output going to std out, so it is not seen in the message area. Run your script from command line instead of from inside the IDE.
This is a workflow used by many users using massive import and image sharing
- making script changes in the IDE
- running script from command line
This makes everything clearer and you can watch the output of longer running script, while they are running.

Revision history for this message
nupur (nupur) said :
#4

Thanks It works :)

Revision history for this message
nupur (nupur) said :
#5

Thanks RaiMan, that solved my question.