简体   繁体   中英

How to organize different java source folders in netbeans (for testing)?

I am developing a project in Netbeans (8.0.2) that uses JUnit (4.x) for testing application code (in a Netbeans module). In the same module I also have some integration tests. I found a way to separate application code, unit tests and integration tests by putting the latter into a separate folder under MODULE_PATH\\test\\qa-functional\\src. By that, the Netbeans IDE puts those three semantical different kinds of classes into individual folders:

Netbeans项目视图具有折叠的源,单元和功能测试包

The problem is, my functional tests tend to grow complex, so I would prefer to have them, well, unit tested. However if create a unit test (in the Unit Test Package) for a class of the functional test package, the test does not compile. Seems to be some class path issues.

Netbeans项目视图具有扩展的源,单元和功能测试包。 IntegrationTestTest.java错误

I know I can put the unit test of the functional test in the functional test package as well (and I will do so if this question does not provide me with some solution), but anyway, is there a way to solve this in Netbeans?

I found a bad solution, changing the order of ant targets in common.xml (in line 610 of NB 8.0.2). But that is obiously not portable, changes with a new version of Netbeans,.. So not really a solution. See details in Netbeans Forum: Classpath problem when unit testing functional tests

In Eclipse, I would simply add a new source folder on the Java build path. But that mechanism does not exist in Netbeans? For clearification, I added a screenshot.

Eclipse软件包浏览器,带有用于src和功能测试代码的单独的单元测试文件夹

Thanks in advance for your help.

You are are trying to do a wrong thing :

  • unit tests should verify the smallest possible functionality, eg that a method is producing the expected result
  • functional tests in NetBeans represent integration tests, tests when you treat the application as a black box

It does not make sense to "unit test" the functionality in the "functional tests". NetBeans treats the tests folders independent so that they are not on each other's classpath, that's why it does not work in NetBeans.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM