Today i had to give a presentation on Junit.
Our team is very young with most of guys having less than 2 yrs of experience .It really hard to convince them to write test cases before coding as we seniors often don’t do that.
I basically covered three scenarios which probably cover 95% of normal coding practise.
To sum up these are:
- When input and output are well defined.Mainly happens in Mathematical logic,say a function returns square of two numbers or nth number in fibocani series.
- When invoking method change the state of input parameter.This is also very common scenario in our day to day code.
- When invoking method changes the state of the system which might effect in future course of actions.Like initialize a system before business logic is implemented .
Presentation went on fine with my emphasis more on how to write Junit in eclipse.It was supposed to be a working demo sort of presentation but during discussion it went on to “How to figure out which functionality needs unit cases” and also how to replicate complex system state in test cases.
Also in the end of discussion a question from our Gui team ,”How to test Swing Gui”?
Now this question is some what complicated ,first we have to figure out what is our intention to test.So on an broader level test cases should be divided int two part .
- Structural testing :To test correct formation of Gui .
- Functional testing : Main candidates are action listeners and validation framework sitting on top of Gui.
If you are Swing Gui developer than i would recommend you to explore the net ,as their are now very good framework available for testing .I was myself shocked to see the kind of open-source projects going by which you can exactly replicate you manual clicking and mouse dragging test cases.