Category: Writing Larger Tests
-
Testing other types of web systems
The higher we go in levels of testing, such as web testing, the more we start to think about the frameworks and environment our application runs in. Our web application is responsive; how do we test for that? If we use Angular or React, how do we test it? Or, if we use a non-relational…
-
DSLs and tools for stakeholders to write tests
We wrote the system tests ourselves with lots of Java code. At this level, it is also common to see more automation. Some tools, such as the Robot framework and Cucumber even allow you to write tests in language that is almost completely natural. These tools make a lot of sense if you want others…
-
Proper code infrastructure is key
Integration and system tests both require a decent infrastructure behind the scenes. Without it, we may spend too much time setting up the environment or asserting that behavior was as expected. My key advice here is to invest in test infrastructure. Your infrastructure should help developers set up the environment, clean up the environment, retrieve…
-
Be careful with methods that are covered but not tested
Larger tests exercise more classes, methods, and behaviors together. In addition to all the trade-offs discussed with larger tests, the chances of covering a method but not testing it are much higher. Vera-Pérez and colleagues (2019) coined the term pseudo-tested methods. These methods are tested, but if we replace their entire implementation with a simple return null, tests still…
-
Perform cost/benefit analysis
One of the testing mantras is that a good test is cheap to write but can capture important bugs. Unit tests are cheap to write, so we do not have to think much about cost. Larger tests may not be cheap to write, run, or maintain. I have seen integration test suites that take hours…
-
How do all the testing techniques fit?
Our goal was to explore techniques that would help you engineer test cases systematically. We discuss a more orthogonal topic: how large should our tests be? I have shown you examples of larger component tests, integration tests, and system tests. But regardless of the test level, engineering good test cases should still be the focus.…
-
Final notes on larger tests
I close with some points I have not yet mentioned regarding larger tests.
-
Patterns and best practices
You probably noticed that the amount of code required to get our first system test working was much greater than. In this section, I introduce some patterns and best practices that will help you write maintainable web tests. These patterns come from my own experience after writing many such tests. Together with Guerra and Gerosa,…
-
Designing page objects
For web applications and system testing, we do not want to exercise just one unit of the system but the entire system. We want to do what we called system testing. What should we test in a web application, with all the components working together and an infinite number of different paths to test? Following what…
-
An introduction to Selenium
Before diving into the best practices, let’s get familiar with the mechanics of writing such tests. For that, we will rely on Selenium. The Selenium framework is a well-known tool that supports developers in testing web applications. Selenium can connect to any browser and control it. Then, through the Selenium API, we can give commands…