Presentation is loading. Please wait.

Presentation is loading. Please wait.

First BlueJ Day Houston, 2006 Unit Testing with BlueJ Bruce Quig Deakin University.

Similar presentations


Presentation on theme: "First BlueJ Day Houston, 2006 Unit Testing with BlueJ Bruce Quig Deakin University."— Presentation transcript:

1 First BlueJ Day Houston, 2006 Unit Testing with BlueJ Bruce Quig Deakin University

2 2 First BlueJ Day, Houston, Texas, 1st March 2006 Outline Introduction Interactive Testing in BlueJ Testing in JUnit Integrating JUnit and BlueJ Demo Questions

3 3 First BlueJ Day, Houston, Texas, 1st March 2006 Introduction Testing is important Introducing testing in first year is hard because –Hard to motivate students to test –Time intensive to do regression testing without support Our contention –Tool support can make it easier to introduce testing into first year curricula

4 4 First BlueJ Day, Houston, Texas, 1st March 2006 Testing in BlueJ Good support for ad-hoc testing –Write code –Construct objects on object bench –Execute methods on objects –Look at the results Immediate feedback after implementation One problem –Tests must be redone by hand –Not good for regression testing (unless patient!)

5 5 First BlueJ Day, Houston, Texas, 1st March 2006 Testing in JUnit Hugely popular framework for performing unit testing in Java Has similar versions for almost every programming language NUnit, PyUnit etc Simple in concept –Each method in the test class starting with test is run independently of all other test methods –Each assertXXX call in the method is evaluated and if one fails, the test method fails –Test class is regular Java Supports Test-Driven Development (TDD)

6 6 First BlueJ Day, Houston, Texas, 1st March 2006 A sample JUnit test class class PersonTest extends TestCase { public void testSetName() { Person mik = new Person(); mik.setName(”Michael"); assertEquals(”Michael", mik.getName()); }

7 7 First BlueJ Day, Houston, Texas, 1st March 2006 Integrating JUnit with BlueJ Goals –Support for writing of standard JUnit test classes, including test-driven development (TDD), for regression testing –Support JUnit source files in BlueJ –Combination of JUnit and BlueJ testing: Recording of user interactions for easy creation of test methods

8 8 First BlueJ Day, Houston, Texas, 1st March 2006 Integrating JUnit with BlueJ Our approach –Use the interaction techniques in BlueJ to construct JUnit unit tests

9 9 First BlueJ Day, Houston, Texas, 1st March 2006 Demo

10 10 First BlueJ Day, Houston, Texas, 1st March 2006 Teaching goals How to create good tests Encourage students to test Knowledge about Test Driven Development Some important problems: –Testing can be boring and seem pointless –Takes time (away from “real” programming)

11 11 First BlueJ Day, Houston, Texas, 1st March 2006 How to create good tests Positive testing EXAMPLE Negative testing EXAMPLE Boundary tests EXAMPLE Bug tests

12 12 First BlueJ Day, Houston, Texas, 1st March 2006 Encourage testing Show the benefits of testing: –Automated tests finds bugs as program is developed. –In BlueJ it is easy to create tests. –Sense of achievement when test passes. –Try to design exercises that include non- trivial bugs. –Give them implementation exercises that are likely to make previously created tests fail.

13 13 First BlueJ Day, Houston, Texas, 1st March 2006 Test Driven Development Testing before implementation. Makes you think about interface before implementation. Popular in agile development processes like eXtreme Programming. Advanced concept that is difficult to do from the very start of a course because it requires : –the method definitions to exist OR –the ability to manually write test

14 14 First BlueJ Day, Houston, Texas, 1st March 2006 How to design an exercise Give students a program with bugs –Non-trivial bugs. (String equality, if(…);{…}) –Have bugs that can be found with positive, negative and boundary tests. Make students write test cases that exposes the bugs. Fix bugs Rerun tests


Download ppt "First BlueJ Day Houston, 2006 Unit Testing with BlueJ Bruce Quig Deakin University."

Similar presentations


Ads by Google