This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197821

Summary: Wrong method's test order
Product: java Reporter: Corisco
Component: JUnitAssignee: Yulia Novozhilova <ynov>
Status: CLOSED INVALID    
Severity: normal CC: Corisco, jskrivanek
Priority: P1    
Version: 7.0   
Hardware: PC   
OS: Windows 7 x64   
Issue Type: DEFECT Exception Reporter:

Description Corisco 2011-04-16 21:54:47 UTC
The tests are been executed in wrong order.

In the main class i have a method 'A' and a method 'B'. In my test class i placed the method 'B' before the method 'A' (both with @Test annotation), but when i run the test (Ctrl + F6), the method 'A' is executed before the method 'B' like the order of them in the main class. It should respect the order of the test class, that is, method B before the method A. If i change the order in the main class then i have the expected result but by the wrong way.
Comment 1 Corisco 2011-04-16 23:18:08 UTC
In fact, i discovered that the test are been made in a ramdon way. It's worse!
Comment 2 Corisco 2011-04-17 18:36:52 UTC
I executed the same test on version 6.9.1 and it doesn't happen.
Comment 3 Jiri Skrivanek 2011-04-18 06:59:13 UTC
It is a nature of JUnit that test cases are not executed in any particular order. Use @Before annotation or some other technique.
http://junit.sourceforge.net/doc/faq/faq.htm#tests_2
Comment 4 Corisco 2011-04-18 08:58:48 UTC
I saw de link you've posted and everything seems right, but why i don't have this behavior in another versions of Netbeans. I am using the same project in nb 7 rc2 and nb 6.9.1. In nb 6.9.1, i donĀ“t need to use @Before or anything else. The methods are executed in the same order they apeear in the class test.
Comment 5 Jiri Skrivanek 2011-04-18 09:05:09 UTC
I don't know if there are some changes in execution in NetBeans7.0.
Comment 6 Yulia Novozhilova 2011-04-18 13:32:40 UTC
NetBeans 7.0 rc2 uses JUnit 4.8.2 while NetBeans 6.9.1 uses 4.5 version of JUnit. I suppose this may cause the difference. Anyway, this is not a bug, so closing.
Comment 7 Corisco 2011-04-18 14:15:17 UTC
(In reply to comment #6)
> NetBeans 7.0 rc2 uses JUnit 4.8.2 while NetBeans 6.9.1 uses 4.5 version of
> JUnit. I suppose this may cause the difference. Anyway, this is not a bug, so
> closing.

It may not be a bug of nb 7 rc2 but you have to agree with that it is a piece of shit! They could implement a way to make a choice about what version of JUnit you want to use. I don't know but i think that i already saw this type of thing in older version of netbeans.

Anyway, thanks!