mercredi 30 janvier 2019

Strategies for DRY Jasmine tests

I'm writing extensive end-to-end tests for an Angular application using Protractor and Jasmine in Typescript. I have a specific problem, and a general problem, related to reusing my test code.

The specific problem: We want to test that our UI is behaving correctly when a user uploads a file. Since our system treats average-sized files differently from very large files, we'd like to run two identical test suites, where the only difference is the size of the file.

I've been using Page Objects to encapsulate details about our UI. That way my tests refer to actions that can be taken on a page, without needing to specify anything about what elements are on the page. But I don't know a good strategy for encapsulating details about the specs themselves --- describe and it blocks kind of seem like magic words to me, rather than methods.

The cut-and-paste strategy for the file upload tests would be, copy the 3 spec files and just change the path to the test file. But what is the clean code strategy for doing this?

Aucun commentaire:

Enregistrer un commentaire