Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Mauricio Aniche

Rating No ratings yet

Go beyond basic testing! Great software testing makes the entire development process more efficient, from understanding your code before you write it to catching bugs in tricky corner cases. Effective Software Testing is a hands-on guide to creating high quality tests, from your first line of code through pre-delivery checks. It’s full of techniques drawn from proven research in software engineering. You’ll learn to efficiently engineer tests specifically for your software and end reliance on generic testing practices that may be right for every project. Effective Software Testing teaches you a systematic approach to software testing. You’ll master easy-to-apply techniques to create strong test suites that are specifically engineered for your code. Following real-world use cases and detailed code samples, you’ll soon be engineering tests that find the bugs hiding in edge cases and the parts of code you would never think of testing! Along the way, you’ll develop an intuition for testing that can save years of learning by trial and error. Purchase of the print b

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Effective Software Testing: A Developer's Guide ## 【One-Line Pitch】 A practical, research-backed guide that transforms software testing from an artistic craft into a systematic engineering discipline, showing developers how to design test cases that actually find bugs. Ideal for working developers who want to move beyond "just writing tests" to engineering high-quality test suites. ## 【Book Arc】 - **Opening (~0%–9%)**: Establishes the core argument that testing can and should be systematized rather than left to intuition or experience. The author shares a personal story from building software for gas pumps on constrained hardware, illustrating how manual testing becomes impractical and why automated, systematic approaches are essential. - **Early (~9%–28%)**: Introduces the testing pyramid and explains why unit tests should form the foundation of your testing strategy. Covers the fundamental difficulty of testing—using the example of a system with 300 boolean flags having more combinations than atoms in the universe—and provides a workflow for integrating testing into development. - **Early-Middle (~28%–38%)**: Dives into specification-based testing, using the `substringsBetween()` function as a running example. Demonstrates exploratory testing first, then shows how to systematically identify input partitions and derive test cases from the specification. - **Middle (~38%–53%)**: Continues with practical techniques for combining partitions pragmatically, using a `NumberUtils.add()` example with parameterized tests. Shows how to avoid combinatorial explosion while maintaining strong coverage, and introduces the three-step process for identifying partitions: examine each input variable, explore variable interactions, and derive test cases. - **Late (~53%–100%)**: Covers structural testing and code coverage, designing contracts with pre- and post-conditions, property-based testing, test doubles and mocks, designing for testability, test-driven development, larger integration tests, and test code quality. ## 【Key Takeaways】 - **Testing can be systematized** (Early): The book's central thesis is that effective testing doesn't require exceptional creativity—it requires a repeatable methodology. This matters because it means any developer can produce high-quality tests with the right techniques. - **The testing pyramid guides resource allocation** (Early): Unit tests form the wide base, with fewer integration tests and even fewer system tests. The rationale is practical: unit tests are fast, deterministic, and easy to write, making them the most efficient way to catch bugs. - **Specification-based testing starts with exploration** (Early): Before formal techniques, write quick exploratory tests to understand what your code does. These informal tests teach you about the behavior and help you identify what needs systematic testing. - **Partition identification is the hardest part of testing** (Middle): The author proposes a three-step approach: examine each input variable individually (type, range, nullability), then explore how variables interact and constrain each other. Missing a partition means potentially letting a bug slip through. - **Don't blindly combine all partitions** (Middle): Combining every partition with every other can explode into hundreds of tests (320 for a simple string function). Be pragmatic—test exceptional cases individually, and only combine partitions where interactions are likely to reveal bugs. - **Parameterized tests are ideal for partition-based testing** (Middle): Using frameworks like JUnit's `@ParameterizedTest` with `@MethodSource` makes it easy to express many test cases cleanly, improving both readability and maintainability of your test suite. - **Code coverage tools complement, not replace, specification testing** (Early): Structural testing via coverage analysis helps you see which lines your tests exercise, but it doesn't tell you whether your tests are good—it only shows what you've covered. ## 【Reading Tips】 - **Deep-read chapters 1–2** (the first ~50% of the book): These establish the systematic methodology and the partition-based testing technique that the rest of the book builds on. The `substringsBetween()` and `NumberUtils.add()` examples are worth working through carefully. - **Skim the testing pyramid discussion** if you're already familiar with unit vs. integration vs. system testing—the key insight is the author's rationale for favoring unit tests, not the pyramid itself. - **Pay special attention to the "be pragmatic" advice** in chapter 2: The author explicitly addresses what to do when combinations explode, which is a real problem you'll face immediately in your own testing. - **The Java code examples are readable even for non-Java developers**: The testing patterns (parameterized tests, assertion libraries) translate directly to other languages and frameworks. - **Use the end-of-chapter exercises** (like the multiple-choice questions in chapter 1) to check your understanding of key trade-offs before moving on. ## 【Coverage Limits】 This guide covers the opening through roughly the middle of the book (specification-based testing). The later chapters on property-based testing, mocks, testability, TDD, and test code quality are not covered in detail here. ##
Page 12
■ Simulating exceptions 157 6.3 Mocks in the real world 158 The disadvantages of mocking 159 ■ What to mock and what not to mock 160 ■ Date and time wrapper...
View in text
Excerpt 2
plain how software developers can perform effective testing together with their development activities. Before we dive into the specific techniques, I descri...
View in text
Excerpt 3
code can guide you through software development. But soft- ware testing is about finding bugs, and that is what this book is primarily about. Systematic an...
View in text
Excerpt 4
right)) eterized .isEqualTo(expected); values } One argument static Stream<Arguments> testCases() { per test case return Stream.of(
View in text
Excerpt 5
re, we have tests T1 to T8, as listed in table 3.1. Table 3.1 Truth table for the if expression from the CountWords program Test case isLetter last == s last...
View in text
Excerpt 6
i = 0; i < half; i++) { left = left + string.charAt(i); right = string.charAt(length - 1 - i) + right; if (left.equals(right)) { size = lef...
View in text
Excerpt 7
stack trace but instead is shown a more elegant error page. If I am modeling business classes but I am not sure whether the data was already cleaned up, I ...
View in text
Excerpt 8
asket.products(); If the basket is if(productsInBasket.isEmpty()) { empty, we skip this action. This may return basket; Picks a happen, as we do...
View in text
Tags
AI categories
Programming LanguageCodeProgramming
ISBN: 1633439933
Publish Year: 2022
Language: English
Pages: 329
File Format: PDF
File Size: 7.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…