CEG491XF-Lecture5.pdf - CEG 491XF Computer Engineering Project I II Testing Verification and Validation Winter 2017 Content 1 Testing Tools for Code

CEG491XF-Lecture5.pdf - CEG 491XF Computer Engineering...

This preview shows page 1 - 7 out of 20 pages.

2/15/2017 1 CEG 491XF Computer Engineering Project I & II Testing Verification and Validation Winter 2017 CEG 491XF –Design of Computer Based Systems 1 Content 1. Testing Tools for Code Developers 2. Junit
Image of page 1
2/15/2017 2 JUnit Introduction JUnit is a regression testing framework Used by developers to implement unit tests in Java Goal: Accelerate programming and increase the quality of code. Part of XUnit family (HTTPUnit, Cactus), CppUnit CEG 491XF –Design of Computer Based Systems 2 Where Does JUnit Come From? JUnit’s web site: Eclipse includes JUnit Eclipse provides new GUI to run JUnit test cases and suites You can run your unit tests outside of Eclipse If you wish using TestRunner Using JUnit’s Window SEG 4140 - Introduction 3
Image of page 2
2/15/2017 3 What is Junit? Test framework provides tools for: – assertions running tests aggregating tests (suites) reporting results Philosophy always the same: Let developers write tests. Make it easy and painless. Test early and test often CEG 491XF –Design of Computer Based Systems 4 Eclipse JUnit Setup Eclipse preferences can be set in the JUnit Preferences window For the most part you can leave these alone Filters needed to identify packages, classes, or patterns that should not be shown in the stack trace of a test failure SEG 4140 - Introduction 5
Image of page 3
2/15/2017 4 Why test? Why Junit?+ Automated tests prove features Tests retain their value over time and allows others to prove the software still works (as tested). Confidence, quality, sleep Effective, open source, integrated Get to code sooner by writing tests. CEG 491XF –Design of Computer Based Systems 6 JUnit Test Cases Test case Runs multiple tests Implemented a subclass of TestCase Define instance variables that store the state of the tests in the class Initialize TestCase by overriding setUp method Clean-up after test case is done by overriding tearDown method SEG 4140 - Introduction 7
Image of page 4
2/15/2017 5 Test infected CEG 491XF –Design of Computer Based Systems 8 It’s a Good Thing, no penicillin needed Immediate gratification with build iterations Start with “The Simplest Thing That Could Possibly Work”. Iterate by successive application of design pattern. Break the cycle of more pressure == fewer tests Reduce code captivity If others can test it, others can work on it. Half my time on tests? Yes, really, half. You’ll spend less time overall Time savings on debugging No time wasted on tracking down a bug introduced days or weeks ago. What debugger? Less reliance on time consuming debuggers. CEG 491XF –Design of Computer Based Systems 9
Image of page 5
2/15/2017 6 Junit Mechanics Define a subclass of TestCase.
Image of page 6
Image of page 7

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture