wtf.g4s8.oot:oot

Object Oriented Testing Framework for Java

License

License

GroupId

GroupId

wtf.g4s8.oot
ArtifactId

ArtifactId

oot
Last Version

Last Version

0.1.7
Release Date

Release Date

Type

Type

jar
Description

Description

wtf.g4s8.oot:oot
Object Oriented Testing Framework for Java
Source Code Management

Source Code Management

https://github.com/g4s8/oot/tree/master/oot

Download oot

How to add to project

<!-- https://jarcasting.com/artifacts/wtf.g4s8.oot/oot/ -->
<dependency>
    <groupId>wtf.g4s8.oot</groupId>
    <artifactId>oot</artifactId>
    <version>0.1.7</version>
</dependency>
// https://jarcasting.com/artifacts/wtf.g4s8.oot/oot/
implementation 'wtf.g4s8.oot:oot:0.1.7'
// https://jarcasting.com/artifacts/wtf.g4s8.oot/oot/
implementation ("wtf.g4s8.oot:oot:0.1.7")
'wtf.g4s8.oot:oot:jar:0.1.7'
<dependency org="wtf.g4s8.oot" name="oot" rev="0.1.7">
  <artifact name="oot" type="jar" />
</dependency>
@Grapes(
@Grab(group='wtf.g4s8.oot', module='oot', version='0.1.7')
)
libraryDependencies += "wtf.g4s8.oot" % "oot" % "0.1.7"
[wtf.g4s8.oot/oot "0.1.7"]

Dependencies

compile (2)

Group / Artifact Type Version
org.hamcrest : hamcrest jar 2.1
net.jcip : jcip-annotations jar 1.0

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.3.1
org.junit.jupiter : junit-jupiter-engine jar 5.3.1

Project Modules

There are no modules declared in this project.

Experimental Object Oriented Testing Framework for Java

EO principles respected here DevOps By Rultor.com

oot: Maven Central, oot-maven-plugin: Maven Central

Build Status Build status CircleCI PDD status License

Concepts

  1. Use single entry points for all tests
  2. Use composition to construct test cases
  3. Control test runs behavior in the code
  4. Write test-cases objects instead of classes with test functions

Prerequirements

Usage

Disable maven-surefire-plugin by adding skipTests property to configuration, add oot-maven-plugin and oot library dependency to pom.xml:

<project>
  <dependencies>
    <dependency>
      <groupId>wtf.g4s8.oot</groupId>
      <artifactId>oot</artifactId>
      <!-- use latest release version or add snapshots repo -->
      <version>1.0-SNAPSHOT</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
      <plugin>
        <groupId>wtf.g4s8.oot</groupId>
        <artifactId>oot-maven-plugin</artifactId>
        <!-- use latest release version or add snapshots repo -->
        <version>1.0-SNAPSHOT</version>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Maven Plugin will be executed on test phase, supported properties are:

  • skipTests - disable tests (optional, default false)

It will search for public class with public static void test method, same as java cli searches for main method.

Hint: check ./oot-example project for real example Maven project.

To write first test, create public test class with method test:

public final MainTest {
  public static void test() {
    // run tests here
  }
}

oot library use TestReport implementations to report test results and fail test phase on test failure. And TestCase implementation to wrap test logic:

public final MainTest {
  public static void test() {
    try (FailingReport report = new FailingReport(new ConsoleReport())) {
      new SimpleTest<>("basic test", () -> 1 + 1, Matchers.is(2));
    }
  }
}

In this example:

  • FailingReport will fail test phase after all tests if any test fails
  • ConsoleReport will print all test results to stdout
  • SimpleTest - generic object to apply Hamcrest matcher to target object

To run multiple tests sequentially use:

new SequentialTests(
  new FooTest(),
  new BarTest(),
  new BazTest()
)

To run it parallelly use:

new ParallelTests(
  new FooTest(),
  new BarTest(),
  new BazTest()
)

Decorating

TestCase has default decorator TestCase.Wrap. It can be used to move all tests composition into main test constructor:

public final class MainTest extends TestCase.Wrap {
  private MainTest() {
    super(
      new ParallelTests(
        new TestOne(),
        new TestTwo(),
        new TestThree()
      )
    );
  }

  public static void test() throws IOException {
    try (FailingReport report = new FailingReport(new ConsoleReport())) {
      new MainTest().run(report);
    }
  }
}

Versions

Version
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0