Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why should we test? How should we test?

Similar presentations


Presentation on theme: "Why should we test? How should we test?"— Presentation transcript:

1 Why should we test? How should we test?
Testing with JUnit Why should we test? How should we test? Arianne Meeting 2010 Markus Keunecke

2 Summary Introduction Testframework JUnit Using JUnit Coverage
Continuous Integration JUnit and Stendhal Conclusion Arianne Meeting 2010 Markus Keunecke

3 Introduction With Testing you want to find errors
Earlier found errors are fixable with much less effort than later found error Existing tests give confidence in making changes Running tests after each change makes it possible to find errors in each change Arianne Meeting 2010 Markus Keunecke

4 Introduction Automated tests ease unit testing
Develop tests parallel to „normal“ functions Extreme: Test driven development Good way of development Make small changes Run tests after each change Commit after having „green bar“ Continuously update your local sandbox Arianne Meeting 2010 Markus Keunecke

5 Testframework JUnit A well known and widely used test framework for java Open source licence Current version is 4.8.1 Integration for Eclipse and Hudson available Find more information at Arianne Meeting 2010 Markus Keunecke

6 Using JUnit Prerequisite: junit.jar must be in class path (or build path for eclipse project) A test case is a class with several test methods Test methods are annotated Test cases can be arranged into test suites: Empty class @RunWith(Suite.class) @SuiteClasses({MyTest.class, AnotherTest.class}) Arianne Meeting 2010 Markus Keunecke

7 Using JUnit Asserts for checking results in your test
Expected exceptions in a test Setting up special requirements before a test Cleaning up after a test Tests can be run in several ways Ant target for automatic builds in hudson or ant based IDEs like Netbeans Eclipse Arianne Meeting 2010 Markus Keunecke

8 Coverage Measurement to get an idea if you have sufficient tests
Measure which code was executed by tests Several kinds of coverages measured by tools Package, Class,Method and Block But: Limited expressiveness as you can gain high coverage without asserting sth. in your tests Arianne Meeting 2010 Markus Keunecke

9 Coverage Example tools: Emma and Cobertura
Emma has a good eclipse integration called EclEmma Cobertura is used on our Continuous Integration server Hudson Arianne Meeting 2010 Markus Keunecke

10 Arianne Meeting 2010 Markus Keunecke

11 Coverage Arianne Meeting 2010 Markus Keunecke

12 Coverage Arianne Meeting 2010 Markus Keunecke

13 Continuous Integration
Ease collaboration Less time spent on finding bugs in interactions between different persons' works Early integration reduces the number of possible changes that broke something Arianne Meeting 2010 Markus Keunecke

14 Continuous Integration
„Check in often and update often“ Run all tests after each change Use automated tests ion.html Arianne Meeting 2010 Markus Keunecke

15 JUnit and Stendhal Stendhal has some test supporting tools
ChatTestCreator *TestHelper-classes located in test folder in the package utilities Stendhal does CI with hudson May have noticed hudson_bot in #arianne tests run every day at about 5:30 am and measure coverage on the hudson Count todos, findbugs analysis, compiler warnings Arianne Meeting 2010 Markus Keunecke

16 Conclusion Learned several things Why test? How to test?
How to determine „enough“ testing? How to get benefit from automated testing How do we use JUnit in Stendhal? But: Unit testing alone is not enough, there are still several other things to be tested by human beings! Arianne Meeting 2010 Markus Keunecke


Download ppt "Why should we test? How should we test?"

Similar presentations


Ads by Google