-
Notifications
You must be signed in to change notification settings - Fork 71
Testing
The integration tests are in review, pull request #222,
We have two integration tests. A back-end only tests and an end-to-end test which tests 3 main scenarios.
We test 3 scenarios:
- Simple server start-up
- Try to use the service with wrong credentials
- Try to play the first level with a default created character
As most of the functionality is accessible using the API or other methods, we use simple requests rather than Selenium (though selenium should be easily be added to the module). Resources are exposed at plain paths inside aimmo-game/service. We can also use minikube with this test, but we need a different nginx configuration for this.
Most of the resources are pooled for multiple times, to give the site enough time for the resource to get deployed.
def __pool_callback(self, callback, tries):
while tries > 0:
tries -= 1
time.sleep(1)
try:
if callback():
return
break
except:
print("Waiting for resource...")
self.assertTrue(False)
The test class has two verbosity levels, the verbose one being useful for when tests don't pass.
For integration test setuptool works differently than the usual automatic package discovery. The test_suite automatic discovery looks for "test_" prefix methods. The automatic test suite is also looking for the corresponding file in the actual package, thus we need a custom_test_suit method to run the tests.
For more information this link may be helpful.
def custom_test_suite():
return unittest.TestLoader().discover('tests', pattern='test_*.py')
setup(
[...]
test_suite="setup.custom_test_suite",
[...]
)