Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example of IMHO well-written test case (written in notepad, please correct if does not compile):</p> <pre><code>import static org.fest.assertions.Assertions.assertThat; public class StudentTest { private final Student student = new StudentServiceImpl(); @Test public void shouldReturnEmptyListOfStudentsWhenNotInitialized() { //given //when List&lt;String&gt; students = student.getStudentList(); //then assertThat(students).isEmpty(); } @Test public void shouldReturnSomeStudentsWhenListCreated() { //given student.createStudentList(); //when List&lt;String&gt; students = student.getStudentList(); //then assertThat(students).containsExactly("John", "Bill", "Ricky", "Jack"); } @Test public void shouldStorePreviouslySetListOfStudents() { //given student.setStudentList(Arrays.asList("Jane", "Bob")); //when List&lt;String&gt; students = student.getStudentList(); //then assertThat(students).containsExactly("Jane", "Bob"); } } </code></pre> <h3>Few tips:</h3> <ol> <li><p>Keep tests short and simple</p></li> <li><p>Test name should describe what use case is being tested</p></li> <li><p>Separate setup code, tested logic and assertions</p></li> <li><p>Code should be easy to read. Use fluent and descriptive libraries like <a href="http://code.google.com/p/fest/" rel="nofollow">FEST</a></p></li> </ol> <h3>Further improvements:</h3> <ol> <li><p>The first test should fail, do you know why?</p></li> <li><p>There are still few tests missing, do you know which ones?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload