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 192942 - [70cat][java][test] When executing a Project Test, all classes in the Test folder are executed. Including Abstract Classes
Summary: [70cat][java][test] When executing a Project Test, all classes in the Test fo...
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-06 19:58 UTC by esmithbss
Modified: 2012-10-26 11:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description esmithbss 2010-12-06 19:58:24 UTC
Product Version = NetBeans IDE Dev (Build 201012060001)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_22
Runtime = Java HotSpot(TM) Client VM 17.1-b03

I currently have a project using JUnit 4 with 5 test classes defined.  In addition to this, I have a Test Suite which launches these 5 tests.

Two of my test classes use an abstract super class named SQLTest to provide common methods for analyzing the results.

When I execute my Test Suite, I receive the results of my 5 tests; however, when I run the "Test" menu option for my project, the test runner attempts to execute the abstract SQLTest class as well.

The abstract class has no tests defined.

Test execution should never attempt to execute an abstract class.
Comment 1 peathal 2012-03-10 22:08:50 UTC
A really nice addition would be to execute the implementations or a choosable if running tests of the abstract class.

I assume here that the "abstract test class"-pattern is used to test several implementations of the same interface. Eg. you have an interface Algorithm. Then we create an abstract AlgorithmTest class with one abstract method:

 Algorithm createAlgorithm() 

and all the test class implementations overwrites this method e.g. via:

class AlgorithmFastTest {
   @Override protected Algorithm createAlgorithm() {
      return new AlgorithmFast();
   }
}
Comment 2 Theofanis Oikonomou 2012-10-26 11:07:24 UTC
AFAIK when you invoke the Test action in the project it runs all *Test.java files in the test folder. A simple fix would be to rename your abstract test class to something like SQLTestAbstract. This solves the issue for me. Please reopen if it does not work for you. Thank you