Exercise Notes

Learning goals

  • Gain familiarity of and follow software testing frameworks and methodologies
  • Conduct a range of test types
  • Test code and analyse results to correct errors found using Integration and other tests

Programs used

Table Tennis League – Continued

This exercise builds on the previous module, so make sure you’ve finished that (not including stretch goals!) first.

Integration tests

Look at game_test.js for a starting point, then add some more integration tests for the app. Make sure they pass! You should be able to write the tests without modifying the app code.

Think about what scenarios to test. What edge cases are already covered by your unit tests? How much effort would it be to test all the edge cases in the integration test?

The trickiest commands to test are those for saving and loading files, because they interact with the file system. Decide how to test these: will you use test doubles or real files? It can be done either way – what are the advantages and disadvantages of each? You could try implementing both, so you can compare them.

Acceptance tests

Cucumber tests

Have a look at game.feature for an example test and steps.js for the corresponding step definitions.

Think about what other scenarios to test. What edge cases are already covered by your unit and integration tests? How much effort would it be to test all the edge cases in the Cucumber tests?

Think about the language you use to write the scenarios. Would they make sense to a non-technical product owner who understands sports leagues but not code?

For this simple app, you are likely to have a lot of overlap with the integrations tests. In a bigger system, particularly one where you can interact directly with the UI, the acceptance tests may be notably more high level. Deciding what level to test each feature is a difficult decision that requires some experience.

Selenium tests

Try writing some Selenium tests as well, as discussed in the reading for this module.

Pick your favourite website (either one you have created yourself, or in the open internet).

  • Think about a handful of acceptance tests that you might want to perform if you were developing the site.
  • Implement them using mocha and Selenium WebDriver.
  • If you are feeling confident, try using Cucumber to write them in a BDD style as well.