https://github.com/dakusui/actionunit
Action programming library for testing
https://github.com/dakusui/actionunit
functional java testing
Last synced: 6 months ago
JSON representation
Action programming library for testing
- Host: GitHub
- URL: https://github.com/dakusui/actionunit
- Owner: dakusui
- License: apache-2.0
- Created: 2016-07-31T05:43:55.000Z (almost 10 years ago)
- Default Branch: 6.1.x
- Last Pushed: 2024-12-08T02:20:52.000Z (over 1 year ago)
- Last Synced: 2025-07-22T12:22:59.206Z (11 months ago)
- Topics: functional, java, testing
- Language: Java
- Homepage: https://dakusui.github.io/actionunit/
- Size: 2.38 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActionUnit
Action based JUnit[[0]] test runner library
[](https://travis-ci.org/dakusui/actionunit)
# Installation
The latest version of ActionUnit requires Java SE8 or later.
Following is a maven coordinate for ActionUnit.
```xml
com.github.dakusui
actionunit
[5.2.0,)
test
```
Also it requires JUnit 4.12 or later. Please make sure you are using it in your dependencies.
# For what is it useful?
Suppose that you want to define your tests in your own DSTL, domain specific testing
language, and want to implement a test runner which performs the test cases defined
in it.
How to define test cases, how to parse them, and how to structure and perform them
are all independent concerns.
```ActionUnit``` takes care of the last two parts among them "how to structure and
perform them".
# Usage
Following is an example of actionunit.
```java
import static com.github.dakusui.actionunit.core.ActionSupport.*;
public class HelloActionUnit {
@Test
public void helloActionUnit() {
List out = new LinkedList<>();
Action action = forEach(
"i",
() -> Stream.of("Hello", "world", "!")
).perform(i ->
sequential(
simple(
"print {s}",
(c) -> System.out.println("<" + i.resolve(c) + ">")
),
simple(
"add {s} to 'out'",
(c) -> out.add("'" + c.valueOf("i") + "'")
)));
ReportingActionPerformer.create(Writer.Std.OUT).performAndReport(action);
}
}
```
This will print out something like
```
```
to stdout, while following is written to stderr
```
[o]helloActionUnit
[o]ForEach (CONCURRENTLY) [Hello, world, !]
[ooo]Sequential (1 actions)
[ooo]print {i}
```
This shows how actions are structured and whether each of them finished normally
or not. ```o``` inside brackets represent how many times they are executed and
finished normally. As you see, an action ```print {i}``` was executed three times
successfully (```[ooo]```). If one a run of an action fails it will be shown as
```E``` or ```F```(the latter is for ```AssertionError```).
More examples are found here[[1]].
And API reference is found here [[2]].
# References
* [0] "JUnit"
* [1] "ActionUnit examples"
* [2] "ActionUnit API reference"
[0]: http://junit.org/junit4/
[1]: https://github.com/dakusui/actionunit/tree/master/src/test/java/com/github/dakusui/actionunit/examples
[2]: https://dakusui.github.io/actionunit/