OOT Maven parent

Object Oriented Testing Framework Maven parent

License

License

GroupId

GroupId

wtf.g4s8.oot
ArtifactId

ArtifactId

parent
Last Version

Last Version

0.1.7
Release Date

Release Date

Type

Type

pom
Description

Description

OOT Maven parent
Object Oriented Testing Framework Maven parent
Project URL

Project URL

https://github.com/oot
Source Code Management

Source Code Management

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

Download parent

Filename Size
parent-0.1.7.pom 7 KB
Browse

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • oot
  • oot-maven-plugin
  • oot-example

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