Coder Social home page Coder Social logo

actionunit's Introduction

ActionUnit

Action based JUnit[0] test runner library

Build Status

Installation

The latest version of ActionUnit requires Java SE8 or later. Following is a maven coordinate for ActionUnit.

    <dependency>
      <groupId>com.github.dakusui</groupId>
      <artifactId>actionunit</artifactId>
      <version>[5.2.0,)</version>
      <scope>test</scope>
    </dependency>

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.

import static com.github.dakusui.actionunit.core.ActionSupport.*;

public class HelloActionUnit {
  @Test
  public void helloActionUnit() {
    List<String> 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


  <world>
  <Hello>
  <!>

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"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.