Best practices | TestCases | Repetitions and reuse
When you start building your TestCases, it's tempting to just quickly copy and paste steps that you need more than once. However, this creates extra work for future-you. If something changes, you have to update multiple TestCases.
To avoid this, we recommend that you repeat or reuse TestSteps so that you can maintain them in a central location. If you change anything, Tosca automatically updates all instances.
Create repetitions
To repeat the same steps within the same TestCase, create repetitions. For example, to test hit counters or change the number of items in a shopping cart.
TestCase without repetitions and with repetitions
Reuse steps
To reuse the same set of steps in multiple TestCases, create TestStepLibraries with Reusable TestStepBlocks. For example, to use the same preparatory steps in multiple tests.
Reusable TestStepBlock Open VIA and sign in in three TestCases
For TestStepLibraries and Reusable TestStepBlocks, there are a few additional things to keep in mind:
-
Create separate TestStepLibraries in projects where you test more than one application, or more than one version of the same application. To modify steps in a Reusable TestStepBlock, you have to check out the library, which locks the library for everyone else. It's better to keep libraries separate. That way, you can work on your project's or version's steps without blocking anybody else from working on theirs.
-
Follow the golden rule for Reusable TestStepBlocks: if you're thinking about reusing parts of a TestCase, this set of steps is a good candidate for a Reusable TestStepBlock. But don't overdo it. Only create Reusable TestStepBlocks for steps that you really intend to reuse, or you risk cluttering up your repository.
What's next
If you haven't yet, check out our other best practices articles.