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 17963 - Ability to run just one test from command line
Summary: Ability to run just one test from command line
Status: STARTED
Alias: None
Product: obsolete
Classification: Unclassified
Component: xtest (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: L Martinek
URL:
Keywords:
: 35857 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-11-22 10:47 UTC by Milan Kubec
Modified: 2006-12-04 08:47 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kubec 2001-11-22 10:47:34 UTC
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.
Comment 1 L Martinek 2002-06-18 17:06:09 UTC
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?
Comment 2 Martin Brehovsky 2003-03-17 15:17:01 UTC
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.
Comment 3 L Martinek 2003-04-01 16:04:42 UTC
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.
Comment 4 Jesse Glick 2003-04-23 17:31:56 UTC
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.
Comment 5 L Martinek 2003-04-24 15:20:39 UTC
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.
Comment 6 Jesse Glick 2003-04-29 18:41:40 UTC
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)
Comment 7 L Martinek 2003-04-30 09:27:09 UTC
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.
Comment 8 Jesse Glick 2003-04-30 15:34:26 UTC
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.
Comment 9 L Martinek 2003-05-01 14:07:19 UTC
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.




Comment 10 Jesse Glick 2003-05-01 15:23:02 UTC
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?
Comment 11 L Martinek 2003-05-01 15:43:52 UTC
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. 
Comment 12 Martin Brehovsky 2003-09-02 11:40:34 UTC
*** Issue 35857 has been marked as a duplicate of this issue. ***