diff --git a/.gitignore b/.gitignore index 0ded2a2277..5f8ab97fb1 100644 --- a/.gitignore +++ b/.gitignore @@ -101,6 +101,7 @@ samples-and-tests/i-am-a-developer/i-am-working-here samples-and-tests/i-am-a-developer/i-am-creating-jobs-here samples-and-tests/i-am-a-developer/i-am-testing-log-levels-here samples-and-tests/i-am-a-developer/i-am-testing-ssl-config-here +samples-and-tests/i-am-a-developer/i-am-testing-auto-test-here samples-and-tests/just-test-cases/attachments samples-and-tests/booking/logs samples-and-tests/booking/tmp diff --git a/framework/pym/play/commands/autotest.py b/framework/pym/play/commands/autotest.py index 403a7a1b5f..b1437602e3 100644 --- a/framework/pym/play/commands/autotest.py +++ b/framework/pym/play/commands/autotest.py @@ -74,18 +74,18 @@ def autotest(app, args): add_options.append('-DrunSeleniumTests') # Handle timeout parameter - weblcient_timeout = -1 + webclient_timeout = None if app.readConf('webclient.timeout'): - weblcient_timeout = app.readConf('webclient.timeout') - + webclient_timeout = app.readConf('webclient.timeout') + for arg in args: if arg.startswith('--timeout='): args.remove(arg) - weblcient_timeout = arg[10:] - - if weblcient_timeout >= 0: - add_options.append('-DwebclientTimeout=' + weblcient_timeout) - + webclient_timeout = arg[10:] + + if webclient_timeout is not None: + add_options.append('-DwebclientTimeout=' + webclient_timeout) + # Run app test_result = os.path.join(app.path, 'test-result') if os.path.exists(test_result): diff --git a/samples-and-tests/i-am-a-developer/tests.py b/samples-and-tests/i-am-a-developer/tests.py index 439db10c2d..6cd55efa6a 100755 --- a/samples-and-tests/i-am-a-developer/tests.py +++ b/samples-and-tests/i-am-a-developer/tests.py @@ -25,6 +25,74 @@ class IamADeveloper(unittest.TestCase): play = None + def testAutoTest(self): + step('Hello, I am testing "play auto-test"') + + self.working_directory = bootstrapWorkingDirectory('i-am-testing-auto-test-here') + + # play new app + step('Create a new project') + + app = '%s/testable-app' % self.working_directory + + with callPlay(self, ['new', app, '--name=TESTABLEAPP']) as self.play: + self.assertTrue(waitFor(self.play, 'The new application will be created')) + self.assertTrue(waitFor(self.play, 'OK, the application is created')) + self.assertTrue(waitFor(self.play, 'Have fun!')) + self.play.wait() + self.assertEqual(self.play.returncode, 0) + + # play auto-test + step('run with auto-test (the normal way)') + + with callPlay(self, ['auto-test', app]) as self.play: + # wait for play to be ready + self.assertTrue(waitFor(self.play, 'BasicTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'ApplicationTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'Application... PASSED ')) + self.assertTrue(waitFor(self.play, 'All tests passed')) + self.play.wait() + self.assertEqual(self.play.returncode, 0) + + # play autotest is also accepted + step('run with autotest (also accepted)') + + with callPlay(self, ['autotest', app]) as self.play: + # wait for play to be ready + self.assertTrue(waitFor(self.play, 'BasicTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'ApplicationTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'Application... PASSED ')) + self.assertTrue(waitFor(self.play, 'All tests passed')) + self.play.wait() + self.assertEqual(self.play.returncode, 0) + + # Run with a --timeout that is longer than the tests take + step('run with auto-test --timeout=60000') + + with callPlay(self, ['auto-test', app, "--timeout=60000"]) as self.play: + # wait for play to be ready + self.assertTrue(waitFor(self.play, 'BasicTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'ApplicationTest... PASSED ')) + self.assertTrue(waitFor(self.play, 'Application... PASSED ')) + self.assertTrue(waitFor(self.play, 'All tests passed')) + self.play.wait() + self.assertEqual(self.play.returncode, 0) + + # Run with a --timeout that is shorter than the tests take + step('run with auto-test --timeout=1') + + with callPlay(self, ['auto-test', app, "--timeout=1"]) as self.play: + # wait for play to be ready + self.assertTrue(waitFor(self.play, 'BasicTest... ERROR ')) + self.assertTrue(waitFor(self.play, 'ApplicationTest... ERROR ')) + self.assertTrue(waitFor(self.play, 'Application... ERROR ')) + self.assertTrue(waitFor(self.play, 'Tests did not successfully complete.')) + self.play.wait() + self.assertNotEqual(self.play.returncode, 0) + + step("done testing auto-test") + self.play = None + def testSSLConfig(self): # Testing ssl config