Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FMI Workshop 2016 - CS 108 Bootcamp - Unit testing

FMI Workshop 2016 - CS 108 Bootcamp - Unit testing

Im zweiten Semester wartet auf die Informatikstudierenden an der
Universität Basel eines der Studien-Highlights: Das Gameprojekt. In
dieser anwednungsbezogenen Vorlesung werden in Gruppen von Studierenden
ein Multiplayerspiel in Java entwickelt. Im vierteiligen CS108 Bootcamp
werden Euch alle Aspekte der Softwareentwicklung erläutert, die für das
Programmierprojekt relevant sind.

Referent: Marcel Neidinger - m.neidinger (at) unibas.ch

More Decks by Fachgruppe Mathematik Informatik Uni Basel

Other Decks in Programming

Transcript

  1. Implementing Unit tests • xUnit tests are the quasi standard

    for unit testing • jUnit provides an implementation for Java • InteliJ: Hover over @Test in Code and Alt+Enter • Eclipse: • Project > Properties > Java Build Path > Add Library > „JUnit“
  2. Terminology of Unit tests • Code under test The unit

    that is being tested • Test fixture The fixed input of a test case we know the outcome • State testing Test code by validating it’s outcome • Mock Dummy implementation for an interface or class with defined output
  3. Structure of Unit tests public class AdderTestSuite {
 private Adder

    adder; @BeforeClass public static void setup() { adder = new Adder(); }
 
 @Before
 public static void before() { adder.clearStack(); }
 
 @Test
 public statc void test_AddTwoPosIntegers()
 {
 assertEquals(adder.add(2,3), 5);
 } } Class-wise Setup Test-wise Setup Testcase