Skip to content

Commit

Permalink
feat: Moved from gradle to ant. Implemented loglevel.
Browse files Browse the repository at this point in the history
* Created new FlingSpec class for configuring the TestRunner.
* Updated jchalk.
* Changed output format.
* Tests are now using fling instead of junit.
  • Loading branch information
sindrets committed Mar 3, 2021
1 parent 67d5716 commit 5557a13
Show file tree
Hide file tree
Showing 49 changed files with 1,361 additions and 779 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf

[*.java]
charset = utf-8
insert_final_newline = true
max_line_length = 100
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
5 changes: 0 additions & 5 deletions .gitattributes

This file was deleted.

15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Compiled output
build

.gradle
.vscode
.settings
.classpath
# Misc
.settings/
.project

# build files
bin
build
.directory
notes.md
.vim/Session.vim
8 changes: 8 additions & 0 deletions .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"lib/*.jar"
],
"java.format.settings.url": "eclipse-formatter.xml"
}

4 changes: 4 additions & 0 deletions .vim/init.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
augroup project_init
au!
au FileType java setlocal et cc=100 tw=100
augroup END
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,54 @@ A test framework for java.

## Usage

Write some tests and annotate your test methods with `TestGroup`. Your test classes may have a constructor as long as it has no parameters.
Write some tests and annotate your test methods with `TestGroup`. Your test
classes may have a constructor as long as it has no parameters.

```java
public class FooTest {
@TestGroup(description = "Testing string")
public void test(TestInitiator suite) {
String s = "foo";
suite.it("should have a length of 3").expect(s.length()).toBe(3);
suite.it("should not be 'bar'").expect(s).not().toBe("bar");
suite.it("should throw").expect(s.chars().limit(-1)).toThrow(IllegalArgumentException.class);
suite.it("should have a length of 3")
.expect(s.length())
.toBe(3);
suite.it("should not be 'bar'")
.expect(s).not()
.toBe("bar");
suite.it("should throw")
.expect(s.chars().limit(-1))
.toThrow(IllegalArgumentException.class);
}
}
```

Compile your test classes and run `fling`.
Compile your test classes and run `fling`.

```sh
$ java -jar fling.jar $classpaths
```

`$classpaths` is a colon (`:`) separated list of classpaths. `fling` will recursively find all methods with the `TestGroup` annotation, in all classes, starting from the given classpaths.
`$classpaths` is a colon (`:`) separated list of classpaths. `fling` will
recursively find all methods with the `TestGroup` annotation, in all classes,
starting from the given classpaths.

## Options

#### `java -jar fling.jar <classpath>[:<classpath>...] [OPTIONS...]`

* `--exclude <GLOB>[:<GLOB>...]`
* A colon separated list of glob patterns matching files that should be excluded from the test.
* `--include <GLOB>[:<GLOB>...]`
* A colon separated list of glob patterns matching files that should be included. If this option is present the provided list of glob patterns will work as a whitelist: any tests not matched by the given patterns will be excluded.
- `--exclude=<GLOB>[:<GLOB>...]`
- A colon separated list of glob patterns matching files that should be
excluded from the test.
- `--include=<GLOB>[:<GLOB>...]`
- A colon separated list of glob patterns matching files that should be
included. If this option is present the provided list of glob patterns will
work as a whitelist: any tests not matched by the given patterns will be
excluded.
- `--loglevel=<INT>`
- The log level controls how verbose the output is. The different levels are:
- `0: NOTHING`
- `1: ERROR` - show errors only
- `2: INFO` - show simplified test results
- `3: TEST_STATUS` - show status for each individual test
- `4: TEST_STDOUT` - show everything printed to stdout during tests
- `>=5: ALL` - default level
Binary file added bin/fling-1.2.0.jar
Binary file not shown.
84 changes: 0 additions & 84 deletions build.gradle

This file was deleted.

93 changes: 93 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<project name="fling" default="build">

<property name="project.name" value="fling" />
<property name="project.version" value="1.2.0" />

<target name="clean" description="Remove all generated files">
<delete dir="build" />
</target>

<target name="compile" description="Compile the program">
<mkdir dir="build/classes/main" />
<javac
srcdir="src/main"
destdir="build/classes/main"
compiler="modern"
target="8"
source="8"
encoding="utf8"
debug="on"
debuglevel="lines,vars,source"
includeantruntime="false">
<classpath>
<fileset dir="lib" includes="*.jar" excludes="*sources.jar"/>
</classpath>
<compilerarg value="-Xlint" />
<compilerarg value="-Xdiags:verbose" />
</javac>
</target>

<target name="compile-test" description="Compile the tests" depends="compile">
<mkdir dir="build/classes/test" />
<javac
srcdir="src/test"
destdir="build/classes/test"
encoding="utf8"
debug="on"
debuglevel="lines,vars,source"
includeantruntime="false">
<classpath>
<pathelement path="build/classes/main"/>
<fileset dir="lib" includes="*.jar" excludes="*sources.jar"/>
</classpath>
</javac>
</target>

<target name="jar" depends="compile" description="Create a jar">
<jar destfile="build/artifacts/fling-${project.version}.jar">
<zipgroupfileset dir="lib" includes="jchalk*.jar" excludes="*sources.jar"/>
<fileset dir="build/classes/main" includes="**/*.class" />
<manifest>
<attribute name="Main-Class" value="io.github.sindrets.fling.Main" />
<attribute name="Implementation-Title" value="${project.name}" />
<attribute name="Implementation-Version" value="${project.version}" />
</manifest>
</jar>
<jar destfile="build/artifacts/fling-${project.version}-sources.jar">
<fileset dir="src/main" includes="**/*.java" />
<manifest>
<attribute name="Main-Class" value="io.github.sindrets.fling.Main" />
<attribute name="Implementation-Title" value="${project.name}" />
<attribute name="Implementation-Version" value="${project.version}" />
</manifest>
</jar>
</target>

<target name="zip" description="Create a zip">
<delete file="build/artifacts/fling-${project.version}.zip"/>
<mkdir dir="build/artifacts" />
<zip destfile="build/artifacts/fling-${project.version}.zip">
<zipfileset dir=".">
<exclude name="build/**"/>
</zipfileset>
</zip>
</target>

<target name="watch">
<exec executable="sh">
<arg value="-c"/>
<arg value="while sleep 1; do find src -path '*.java' | entr -ds 'ant jar'; done"/>
</exec>
</target>

<target name="test" depends="compile-test" description="Run tests">
<java jar="bin/fling-1.2.0.jar" failonerror="true" fork="true">
<arg value="build/classes/main:build/classes/test:lib/jchalk-1.1.0.jar"/>
<arg value="--exclude=**/mock/*" />
<arg value="--loglevel=3" />
</java>
</target>

<target name="build" depends="jar,test" />
</project>
Loading

0 comments on commit 5557a13

Please sign in to comment.