adding software testing to programming assignments

adding software testing to programming assignments PowerPoint PPT Presentation


  • 135 Views
  • Updated On :
  • Presentation posted in: Sports / Games

Related searches for adding software testing to programming assignments

Download Presentation

adding software testing to programming assignments

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


1. Adding Software Testing to Programming Assignments Stephen Edwards [email protected] Virginia Tech Dept. of Computer Science http://people.cs.vt.edu/~edwards/ http://web-cat.sourceforge.net/

2. ? Workshop: Adding Software Testing to Programming Assignments ?

3. ? Workshop: Adding Software Testing to Programming Assignments ? My goals today are to … Answer these questions: How can I add software testing to my assignments? How can I assess student testing efforts? How can I write “testable” assignments? And show you some live examples!

4. ? Workshop: Adding Software Testing to Programming Assignments ? Why software testing? Students cannot test their own code Want a culture shift in student behavior A single upper-division course would have little impact on practices in other classes So: Systematically incorporate testing practices across many courses

5. ? Workshop: Adding Software Testing to Programming Assignments ? Practicing software testing will help students frame and carry out experiments The problem: too much focus on synthesis and analysis too early in teaching CS Need to be able to read and comprehend source code Envision how a change in the code will result in a change in the behavior Need explicit, continually reinforced practice in hypothesizing about program behavior and then experimentally verifying their hypotheses

6. ? Workshop: Adding Software Testing to Programming Assignments ? What tools and techniques should I teach? We want to start with skills that are directly applicable to authentic student-oriented tasks Don’t want to add bureaucratic busywork to assignments Without tool support, this is a lost cause! It is imperative to give students skills they value … But most textbooks only give a “conceptual” intro to idealized industrial practices, not techniques students can use in their own assignments

7. ? Workshop: Adding Software Testing to Programming Assignments ? Test-driven development is very accessible for students Also called “test-first coding” Focuses on thorough unit testing at the level of individual methods/functions “Write a little test, write a little code” Tests come first, and describe what is expected, then followed by code, which must be revised until all tests pass Encourages lots of small (even tiny) iterations See CD for on-line references

8. ? Workshop: Adding Software Testing to Programming Assignments ? Students can apply TDD in assignments and get immediate, useful benefits Conceptually, easy for students to understand and relate to Increases confidence in code Increases understanding of requirements Preempts “big bang” integration

9. ? Workshop: Adding Software Testing to Programming Assignments ? TDD tools are widely, freely available Lots of open-source tools, particularly for OO languages JUnit (for Java): http://www.junit.org XUnit links (for other languages): http://www.xprogramming.com/software.htm We use tools like this for Java, C++, Scheme, Prolog, and even Pascal in our courses

10. ? Workshop: Adding Software Testing to Programming Assignments ? My goals today are to … Answer these questions: How can I add software testing to my assignments? How can I assess student testing efforts? How can I write “testable” assignments? And show you some live examples!

11. ? Workshop: Adding Software Testing to Programming Assignments ? There are five main strategies to adding testing to programming assignments: Use test cases as specifications Write “acceptance tests” for grading Require student-written tests as part of the assignment Use a reference model to assess student tests Write assignments that focus on testing and/or debugging instead of writing code

12. ? Workshop: Adding Software Testing to Programming Assignments ? There are five main strategies to adding testing to programming assignments: Use test cases as specifications Write “acceptance tests” for grading Require student-written tests as part of the assignment Use a reference model to assess student tests Write assignments that focus on testing and/or debugging instead of writing code

13. ? Workshop: Adding Software Testing to Programming Assignments ? A simple example will ground the discussion: our first live demonstration! Let’s switch to an IDE for this example I’ll use Eclipse and Java first, but similar techniques apply in other IDEs or OO languages I’ll also show what the code looks like in C++ If you visit the workshop web site after the tutorial, you can find this under “Example 1: Building a Gradebook”

14. ? Workshop: Adding Software Testing to Programming Assignments ? What does a test case look like? With XUnit, tests are written as code—usually as individual methods in a special class containing a group of tests All test cases start with the same “world” of objects in the same state: a test fixture Two helper methods setUp() and tearDown() this test fixture public void testNoAssignment() { assertEquals( 0, fred.assignmentAverage() ); }

15. ? Workshop: Adding Software Testing to Programming Assignments ? A longer test case … public void testAssignment1() { fred.addAssignment( 70 ); assertEquals( 70, fred.assignmentAverage() ); fred.addAssignment( 80 ); assertEquals( 75, fred.assignmentAverage() ); fred.addAssignment( 60 ); assertEquals( 70, fred.assignmentAverage() ); wilma.addAssignment( 60 ); assertEquals( 60, wilma.assignmentAverage() ); wilma.addAssignment( 65 ); assertEquals( 62, wilma.assignmentAverage() ); }

16. ? Workshop: Adding Software Testing to Programming Assignments ? Tools make running tests easy Most XUnit frameworks include test runners that allow you to directly execute test cases from one class or many Often, either textual or graphical output is available Many IDEs include direct support for running such test cases (BlueJ, DrJava, Eclipse, …)

17. ? Workshop: Adding Software Testing to Programming Assignments ? You can use test cases as assignment specifications To make an assignment writeup less ambiguous and easier for students to apply or understand … You can write test cases and place them right in the assignment description Concretely, clearly defines the extent of the expected behavior If it is not in a test case, it isn’t required Encourages students to use the test cases

18. ? Workshop: Adding Software Testing to Programming Assignments ? Using test cases as assignment specifications An example: If the assignment is to write Student and Gradebook classes … Include an instructor-written StudentTest class in the assignment spec Include an instructor-written GradebookTest class in the assignment spec Instruct students to refer to these tests to clarify any questions about expected program behavior

19. ? Workshop: Adding Software Testing to Programming Assignments ? Assessing test cases in assignment specifications Pros: Students learn about test cases and how to use them Greater clarity and precision in assignments Easy to combine with “acceptance tests” Cons: Students don’t learn to write tests Least impact on student behavior

  • Login