Jump to content

Core Java Lo Simple Question..


Recommended Posts

Posted

Advanced Calculator Testing:SetUp
Addition
Advanced Calculator Test:TearDown
Advanced Calculator Testing:SetUp
Subtraction
Advanced Calculator Test:TearDown
Advanced Calculator Testing:SetUp
Division
Advanced Calculator Test:TearDown
Advanced Calculator Testing:SetUp
Multiplication
Advanced Calculator Test:TearDown

Above is the result of a simple JUNIT test case.

kani nenu JUNIT lo first Dvision, Multiplication, Addition, Subtraction rasanu.
Why JVM is not following the order of methods I wrote ? Is there any way it is coming up with the order of execution ?
Methods LIFO antaru kada. Even it is not following it.

Java experts, please help.

Thanks in advance
JK.

Posted

Itlanti qstns jntu lab lo internal lo adagadaniki panikosthaii realtime proj lo avasaram le Ani neechukole itlantivi

Anyway ltt

Posted
:) :)
sory naku telidu.
just now starting Java. So, not sure what is ok for real time and what is not.
But thanks for ur reply.

ltt enti ?
Posted

juint does't give gurentee for order of execution ..... very imp to remember ... each Junit method should be independent of other method ... so one method should not depend on other method's outcome.... so order is not imp.....

to answer u r question , if you still want to maintain order .....write one more test method like below

public void testOrder(){

testAdd();
testMultiply();
testDivision(); // the wany u want the order .....


}

Posted

post it here bayya if you havent already [url="http://www.andhrafriends.com/topic/411946-javaj2ee-discussions/page__st__810"]http://www.andhrafri...s/page__st__810[/url]

Posted

there is no guarantee to order of test methods in Junit .. If you are very particular about order there is another framework called TestNg that can give a annotation called "dependson" which can help you order the tests .. In Junit4 there is a partular annotation ..check the below post [url="http://stackoverflow.com/questions/3693626/how-to-run-test-methods-in-specific-order-in-junit4"]http://stackoverflow.com/questions/3693626/how-to-run-test-methods-in-specific-order-in-junit4[/url]

×
×
  • Create New...