简体   繁体   中英

testng.xml compile classes not included in it

I have a project with lots of classes with various tests. And I have a testng.xml file where I directly point what classes should be run. Some of my classes have errors (cause their content is not actual, or I call to some methods that don't exist) I point in testng.xml only actual classes with tests that call correct methods. I run via testng.xml, not via 'main' class. But it looks like testng.xml compiles all the project and founds errors in other classes. Why does it happen? Why compiler run through all classes but not only chosen ones?
Is there any ability to prevent it?

TestNG is a testing framework , not a build tool nor anything else. You said

it looks like testng.xml compiles all the project and founds errors in other classes

but TestNG is not meant to compile anything.

Upon testing, the compiler will compile all class files contained in your source folders (and test sources folders). If you don't want specific classes to be compiled, you must manually exclude them from compilation.

TestNG will only run the tests you've selected but everything that should be compiled will be and I don't think TestNG can have any sort of impact regarding that matter. A quick fix would be to comment anything that prevent compilation from ending successfully. I do this sometimes when I find myself in the same situation as you are : tests half-done but in the need of running some of them nonetheless (in which case I comment entire methods or even entire test classes).

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