From the course: Programming Foundations: Test-Driven Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Test structure

Test structure - Java Tutorial

From the course: Programming Foundations: Test-Driven Development

Start my 1-month free trial

Test structure

- [Instructor] When you write your first test case, you start with one test class per code class. For the Hangman game, the team created one Test Hangman class for one Hangman class. As you write more test cases, the code in the code class continues to grow. At some point, you will see that your code class is becoming bloated. In such a scenario, you will refactor and split your code class. For example, the team may decide to split the Hangman class into two, keeping the scoring logic into a class called as HangmanScores. Should you then create a new test class? You may, if it helps keep your test cases more manageable, or, you may split the code class into two, but continue to use the same test class. Similarly, you may continue to have the same code class, but decide to split the test cases into two, one focusing on the words, and the other on scoring. There's no strict rule that a test class cannot test more than one…

Contents