1

I'm unit testing an Android app using Monkeyrunner with Jython on Eclipse.

  • Eclipse: 4.2.1
  • Eclipse plugin PyDev: 2.7.1
  • Jython: 2.5.3

When running the tests I would like it to fail at the first assertion failure.

Shortened test script:

if __name__ == '__main__':
#    unittest.main()

    mDevice = getConnection()
    runner = unittest.TextTestRunner()
    suite = unittest.TestSuite()

    #----------------------------------------------
    suite0001 = unittest.TestLoader().loadTestsFromTestCase(Test_TEST0001)
    suite.addTest(suite0001)    

    runner.run(suite)

I've read about setting some failfast parameter on this discussion: How to use TextTestRunner class from Python unittest module in failfast mode?

So I try to set this parameter like this:

    ...
    runner = unittest.TextTestRunner(failfast=True)
    ...

However, when running the script, it fails:

  File "c:\svnrepository\x\trunk\JythonProject\src\main.py", line 1361, in <module>
    runner = unittest.TextTestRunner(failfast=True)
TypeError: __init__() got an unexpected keyword argument 'failfast'

Any suggestion?

Community
  • 1
  • 1
gpo
  • 3,388
  • 3
  • 31
  • 53

1 Answers1

0

-f, --failfast Stop the test run on the first error or failure.

New in version 2.7: The command-line options -b, -c and -f were added.

failfast was added in 2.7, monkeyrunner uses 2.5.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Thanks for your answer! Does this mean that there is no other way to stop at first failure with monkeyrunner? – gpo Feb 12 '13 at 10:31