This PR is for refactoring the command line too (Launcher) to add the xtc command so that we can run tests using xtc test and add flexibility to be able to easily add other sub-commands to xtc.
The code in the PR introduces a new "command" framework to add a hierarchical command structure, where commands can have sub-commands, which could have more sub-commands and so on. For example, xtc is a command that has a sub-command test so on the command line it is executed using xtc test <flags...>
The PR also introduces code to represent command line flags. The FlagSet represents a set of flags parsed from the command line. Each command has a set of valid flags. Each Flag in a FlagSet is types, for example a boolean flag, string flag, etc. Flags and parsing a FlagSet is posix compliant. Each flag must have a long name (which is used prefixed with -- on the command line. Optionally a Flag can have a single character shortcut (used prefixed with a - on the command line). Single characters can be concatenated on the command line (e.g. -abc is the same as -a -b -c)
Running Ecstasy Tests
The PR also add a simple test executor to make the xtc test command work. No-arg methods annotated with @Test will be executed in a module that imports xunit.
The FizzBuzz module under manualTests has had tests added to it.
If you build the local distribution, for example:
gradle xdk:installWithLauncherDist
Then export XDK_HOME to point to the distribution (e.g. on my Arm Mac)
cd manualTests
xtc build FizzBuzz
xtc test FizzBuzz
which should print something like...
Starting test execution for module TestFizzBuzz
Executing tests in TestFizzBuzz:
Passed: void shouldBeFizz() in TestFizzBuzz:
Passed: void shouldBeBuzz() in TestFizzBuzz:
Passed: void shouldBeFizzBuzz() in TestFizzBuzz:
Passed: void shouldBeNumber() in TestFizzBuzz:
Executed tests in TestFizzBuzz: Passed=4 Failed=0
Completed test execution for module TestFizzBuzz
Passed: 4
Failed: 0
Individual tests can be executed using the --test (or -t) flag for xtc test. The --test flag can be used multiple times.
The format of the value for the --test flag is <class-name>#<method-name>where <class-name> and <method-name> can be exact name or a sort of reg-ex pattern. Any dot '.' character in the pattern will match a dot in the test name, so not the same ad dot in a normal regex. A star * in the pattern is the same as (.*) in a normal reg-ex.
Either the class name or method name may be omitted, so <class-name> or #<method-name> are also valid.
If the value passed to the --test flag starts with a ! then matches to the filter will be excluded from the run. If a test matches both an include and and exclude filter, the include takes precedence.
For example:
To execute all tests in the class TestFizzBuzz
xtc test --test 'TestFizzBuzz'
To execute the test shouldBeBuzz in class TestFizzBuzz
xtc test --test 'TestFizzBuzz#shouldBeBuzz'
To execute all tests methods containing Fizz
xtc test --test 'TestFizzBuzz#*Fizz*'
To execute the test shouldBeBuzz in any class
xtc test --test '#shouldBeBuzz'
To NOT execute the test shouldBeBuzz in class TestFizzBuzz prefix the pattern with the "!" character
Introduction
This PR is work in progress.
This PR is for refactoring the command line too (Launcher) to add the
xtc
command so that we can run tests usingxtc test
and add flexibility to be able to easily add other sub-commands toxtc
.The code in the PR introduces a new "command" framework to add a hierarchical command structure, where commands can have sub-commands, which could have more sub-commands and so on. For example,
xtc
is a command that has a sub-commandtest
so on the command line it is executed usingxtc test <flags...>
The PR also introduces code to represent command line flags. The
FlagSet
represents a set of flags parsed from the command line. Each command has a set of valid flags. EachFlag
in aFlagSet
is types, for example a boolean flag, string flag, etc. Flags and parsing aFlagSet
is posix compliant. Each flag must have a long name (which is used prefixed with--
on the command line. Optionally a Flag can have a single character shortcut (used prefixed with a-
on the command line). Single characters can be concatenated on the command line (e.g.-abc
is the same as-a -b -c
)Running Ecstasy Tests
The PR also add a simple test executor to make the
xtc test
command work. No-arg methods annotated with@Test
will be executed in a module that importsxunit
.The
FizzBuzz
module undermanualTests
has had tests added to it. If you build the local distribution, for example:Then export
XDK_HOME
to point to the distribution (e.g. on my Arm Mac)Then build
FizzBuzz
and test itwhich should print something like...
Individual tests can be executed using the
--test
(or-t
) flag forxtc test
. The--test
flag can be used multiple times. The format of the value for the--test
flag is<class-name>#<method-name>
where<class-name>
and<method-name>
can be exact name or a sort of reg-ex pattern. Any dot '.' character in the pattern will match a dot in the test name, so not the same ad dot in a normal regex. A star*
in the pattern is the same as(.*)
in a normal reg-ex.Either the class name or method name may be omitted, so
<class-name>
or#<method-name>
are also valid.If the value passed to the
--test
flag starts with a!
then matches to the filter will be excluded from the run. If a test matches both an include and and exclude filter, the include takes precedence.For example: To execute all tests in the class
TestFizzBuzz
To execute the test shouldBeBuzz in class
TestFizzBuzz
To execute all tests methods containing
Fizz
To execute the test shouldBeBuzz in any class
To NOT execute the test shouldBeBuzz in class
TestFizzBuzz
prefix the pattern with the "!" character