Thursday, June 23, 2016

Software Testing Lab : Session II

Here, we shall look at JUnit first.  

1.  Introduce Agile Practices and Test Driven Development (TDD).


2.  Introduce JUnit.  Many tutorials are available that introduce testing as well as JUnit.  For example,
     http://www.vogella.com/tutorials/JUnit/article.html
     http://realsearchgroup.org/SEMaterials/tutorials/junit/junit_tutorial_3.1.html

    Discuss the JUnit framework as well as the constructs that are part of JUnit.  Usually, I get them to download required software and do the above after giving the click for 'Download'.  At the end of the session, the students would have got the material and software ready to implement.

3.  Start with the first exercise.
   
     The students follows Test Driven Development methodology to write the test first (JUnit), which will fail.  Run the code and check if it fails.  Now, write the code that will pass the test.

Write test cases and methods for all of the below methods :  
     add(int a, int b)
     subtract(int a, int b)
     multiply(int a, int b)
     divide (int a, int b)

If it is for novice level students, do not introduce 'Setup()' and 'TearDown()' methods.  It is better to introduce in the next session.  In case students have prior introduction to testing, it is better to get them to design and write test cases with setup() and teardown() methods in mind.

Evaluation :
a.  Check if student has considered the possible scenarios for setup() and teardown().
b.  Time taken for each session depends on the strength and weakness of the class.  So, it has to be decided by the instructor.


Addendum :  Please leave a comment.  Suggestions, comments, discussions and queries are most welcome. 

No comments:

Post a Comment