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.
There should be a way how to run one test from command line without modification of cfg file. There is already empty testbag which can be used for it. But the testbag cannot be completly empty it must contain testset with dir e.g. unit/src it means where tests are stored. Example can be seen in openide/test/cfg-unit.xml. Command line than must look like e.g. this: ant -Dxtest.includes='org/openide/options/*Test.class' -Dxtest.attribs=empty It would require adding such empty testbag to all cfg files and for all folders currently used in each module and for all executors.
The empty testbag contains testset with src dir and witch executor (compiler) should be used. All theses information would have to be in commandline, e.g. ant -Dxtest.testset.dir=unit/src -Dxtest.includes='org/openide/options/*Test.class' -Dxtest.executor=code Is it still convenient? Now you can say which testbag to execute, see issue #20172. Isn't better to edit one testbag and then execute it?
Maybe XTest could create the "empty" testbag by default (if not overriden in the config) - so users do not have to explicitly specify it in the config file.
Fixed in private branch, will be marged to trunk later. To execute one test, type ant -Dxtest.run.singletest=org/openide/options/*Test.class It will use default executor, compiler and resultsprocessor (You have to define them). Tests is taken from directory ${xtest.testtype}/src.
Two notes: (1) See sample script at http://xtest.netbeans.org/servlets/ProjectDownloadList which tries to make it convenient to run 1 test from inside NB. Would be improved by this new flag. (2) Sometimes you need a different testbag than 'empty', if you are using a special executor - e.g. 'emptyide' to run 1 test in IDE mode.
Using property xtest.run.singletest is for easy execution of one test. If you need other special settings use old way of execution with empty testbag.
Could you please document how to do it? I cannot get it to work. ant -f openide/test/build.xml -Dxtest.run.singletest=org/openide/modules/SpecificationVersionTest fails: file:/space/src/nb_all/xtest/lib/module_harness.xml:620: You have to set default executor when executes single test. (with no instructions for how to do that). -Dtbag.executor=code does not work, even with -Dxtest.testtype=unit. Worse, the old style does not seem to work anymore: ant -f openide/test/build.xml -Dxtest.includes=org/openide/modules/SpecificationVersionTest -Dxtest.attribs=empty fails with an error: java.lang.NullPointerException at org.netbeans.xtest.harness.Testbag$Testset.getIncludes(Testbag.java:264) at org.netbeans.xtest.harness.MTestExecutor.createJUnitTestRunnerPropertyFile(MTestExecutor.java:218) at org.netbeans.xtest.harness.MTestExecutor.execute(MTestExecutor.java:169)
Default executor have to be set in cfg file. See http://xtest.netbeans.org/xtest_config.html#how-to-execute-tests and http://xtest.netbeans.org/xtest_config.html#default. The exception is bug. I will fix it.
So is there no way to explicitly specify the executor to use when passing -Dxtest.run.singletest? That could be annoying; assuming we add default="true" to the <executor name="code" .../> entries of */test/cfg-unit.xml, you would only be able to run code-executor tests in single mode, not ide-executor tests.
NPE is fixed, but test is executed only if test in property xtest.includes contains ".class": ant -f openide/test/build.xml -Dxtest.includes=org/openide/modules/SpecificationVersionTest.class -Dxtest.attribs=empty Did it work for you without ".class" in old xtest? I think it didn't. Regarding -Dxtest.run.singletest and default executor issue: Beside executor you also have to specify compiler and resultsprocessor. It would be better to pass name of testbag from which this information will be taken. This testbag shouldn't be empty, it will not be executed. Currently property xtest.testbags is used for executing testbags selected by name so this property could be used. It would look like this: ant -f openide/test/build.xml -Dxtest.run.singletest=org/openide/modules/SpecificationVersionTest.class -Dxtest.testbags=emptyide_testbag There is problem that property xtest.testbags can contain more testbags separated by comma. In case when -Dxtest.run.singletest is used only one testbag will be allowed.
Using xtest.includes without a trailing .class never worked, just a typo. That would account for some problems. But I still can't get it to work. Your last example does not work: file:/space/src/nb_all/xtest/lib/module_harness.xml:620: You have to set default executor when executes single test. Nor does using empty_testbag, nor this which includes a real testbag from cfg-unit.xml as far as I can tell: ant -f openide/test/build.xml -Dxtest.run.singletest=org/openide/modules/SpecificationVersionTest.class -Dxtest.testbags=testbag_1 However ant -f openide/test/build.xml -Dxtest.includes=org/openide/modules/SpecificationVersionTest.class -Dxtest.attribs=empty does work, except for an exception when using 1.4.2 (reported elsewhere). I'm actually not sure what the purpose of xtest.run.singletest *is*, since the proposed syntax is nearly the same as the syntax that already worked. Is it primarily useful for tests located in strange places that do not yet have config files?
Using -Dxtest.run.singletest with -Dxtest.testbags doesn't work now, I just wrote how it could be implemented. Main reason for adding -Dxtest.run.singletest was to be able to execute one test without creating empty testbag in config.
*** Issue 35857 has been marked as a duplicate of this issue. ***