Commit 3e8dccac authored by Stein Eldar Johnsen's avatar Stein Eldar Johnsen 💬

Prepare for gitlab.

parent a9214478
Pipeline #29720758 passed with stages
in 1 minute and 27 seconds
# Mobile Tools for Java (J2ME)
# Package Files #
# virtual machine crash logs, see
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=.m2/repository -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "-B -fae --settings .m2/settings.xml"
MAVEN_NO_TESTS: "-DskipTests=true"
- testing
- release
- post-release
- .m2/repository
.verify: &verify
stage: testing
- $CI_COMMIT_MESSAGE =~ /\[silent-ignore\]/
- $CI_COMMIT_MESSAGE =~ /\[maven-release-plugin\]/
- mkdir -p .m2/repository
- |
cat <<EOF > .m2/settings.xml
- mvn ${MAVEN_CLI_OPTS} verify
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print int(100*covered/instructions), "% covered" }' target/site/jacoco-ut/jacoco.csv
- |
# Report coverage when: BRANCH=develop JOB=verify:jdk8
if [[ "${CI_JOB_NAME}" == "verify:jdk8" && "${CI_BUILD_REF_NAME}" == "master" ]]
echo "Sending jacoco coverage report to"
curl -s | bash -s
coverage: /([0-9]{1,3}) % covered/
# Never cache the snapshot build.
- rm -rf .m2/repository/net/morimekta/utils/io-util/*-SNAPSHOT/
<<: *verify
image: maven:3.5-jdk-8-alpine
<<: *verify
image: maven:3.5-jdk-11-slim
This diff is collapsed.
Testing Utilities
This module contains a number of utilities and helpers to help with testing.
It is based on the [junit 4]( paradigms, but may be
updated to work with [junit 5]( when that is out and
stable. It consists of a number of mostly independent parts.
### Concurrency and Time
In the concurrency and time group you have the `FakeClock` and two fake
`ExecutorService` implementations. These are designed so that you can modify
the clock as time goes on, and that will in turn trigger the executor to do
scheduled tasks. E.g.:
class MyTest {
private FakeClock clock;
private FakeScheduledExecutor executor;
public void setUp() {
clock = new FakeClock();
executor = new FakeScheduledExecutor(clock);
public void testSomethingScheduled() {
Something something = new Something();
executor.schedule(something, 10, TimeUnit.SECONDS);
assertThat(something.isComplete(), is(false));
clock.tick(10, TimeUnit.SECONDS);
assertThat(something.isComplete(), is(true));
There is also a simpler `ImmediateExecutor` that is a simple `ExecutorService`
(not scheduled), and will run all tasks immediately. Note that this may cause
problems if you have tasks that spawns new tasks all the time.
### Terminal Input and Output
When having a program (or module) that prints to standard out, error or needs
input from standard in, you need to emulate a real console or terminal. With
the `ConsoleWatcher` you can easily emulate standard in input, and get whatever
was written to standard out to be verified in the test. E.g.:
class MyTest {
ConsoleWatcher console = new ConsoleWatcher().dumpOnFailure();
public void testSomething() {
console.setInput('a', '\n', Char.ESC);
AtomicInteger exit = new AtomicInteger(0);
MyProgram program = new MyProgram() {
protected void exit(i) {
assertThat(console.getOutput(), is(""));
assertThat(console.getError(), is("Invalid input: " + Strings.escape(Char.ESC)));
assertThat(exit.get(), is(1));
### Extra Matchers and Utils
There is also a set of extra matchers following the hamcrest matcher
interface. All of these are static methods of the `ExtraMatchers` class.
* `equalIgnoreIndent`: Same as isEqualIgnoreSpaces, but only ignores
differences in spaces before the first printable character on *each line*. All
other space chars must match.
* `equalToLines`: Is essentially the same as a string-based `equalTo`, but will
make a line by line diff-based output instead of the standard char-by-char output.
If a rather large multi-line string is compared, it may simplify debugging quite
a lot to get the right failure output.
* `allItemsMatch`: Is a matcher that takes any collection, and compares every item
in that collection with a given matcher.
* `oneOf`: Is a matcher that checks that the given value is one of the expected
values. This forwards to a hamcrest matcher.
* `distinctFrom`: Is a matcher that takes any collection, compares it to another
collection, and checks that there are no common items between the two.
* `inRange`: checks that a number is in a specific numeric range. E.g.
`assertThat(sut.getNumSeals(), is(inRange(0, 10)))` will check that 'getNumSeals()'
returns a vlaue of [0..9] respectively (inRange follows the lower-inclusive,
higher-exclusive range standard).
* `matchesRegex`: Is a string matcher that checks if the string matches a specific
regex. It uses the standard java Pattern syntax.
It is also common to have test resources that needs to be moved into temporary
folders for a specific method to be able to be tested. The `ResourceUtils` class
has a number of helper methods related to this.
\ No newline at end of file
- ".m2/**/*"
- ".git/**/*"
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment