sqtf

A lightweight testing framework

License

License

GroupId

GroupId

com.github.bradleywood
ArtifactId

ArtifactId

sqtf
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

pom
Description

Description

sqtf
A lightweight testing framework
Project URL

Project URL

https://github.com/BradleyWood/Software-Quality-Test-Framework
Source Code Management

Source Code Management

https://github.com/BradleyWood/Software-Quality-Test-Framework

Download sqtf

Filename Size
sqtf-1.1.pom 2 KB
Browse

How to add to project

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

Dependencies

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

Project Modules

  • sqtf-core
  • sqtf-provider

Software-Quality-Test-Framework

A lightweight software testing framework that can be integrated with maven projects.

How to define a test

Tests must be publicly accessible non-static methods with no arguments. Tests must also be marked with @Test (org.sqtf.annotation.Test) annotation.



@Test(expected = ArithmeticException.class)
public void divideByZeroTest() {
    int a = 5 / 0;
}



@Test annotation

The Test annotation has two optional parameters: expected and timeout. Expected denotes the expected exception type to be thrown and timeout is an integer value measured in milliseconds. Tests that fail to complete within the timeout will be terminated and marked as failure.

How it works

Tests are dynamically loaded based on the specified test class root. Reflection is used to find and invoke all test methods.

Running from the command-line

The first argument should always be a relative path to the test class root folder. The next argument is optional and denotes the output directory for the detailed test reports.

To view the results graphically run with

-display

Parameterized tests

Parameterized tests can be easily implemented and accept test data from various sources including methods and csv files. The test data is automatically converted to match the parameter types of the test. Data that cannot be converted to match the parameter types of the test will result in test failure.

Use test data from a CSV File

@Test
@Parameters(source = "testData/add_csv_data.csv")
public void parameterizedAdd(int a, int b, int expected) {
    Assert.assertEquals(expected, a + b);
}

Use test data from local static or instance methods

@Test
@Parameters(source = "dataGenerator")
public void parameterizedAdd(int a, int b, int expected) {
    Assert.assertEquals(expected, a + b);
}

public Collection dataGenerator() {
    List<Object[]> lst = new ArrayList<>();
    lst.add(Arrays.asList(0, 0, 0));
    lst.add(Arrays.asList(10, 20, 30));
    lst.add(Arrays.asList(100, 200, 300));
    return lst;
}

Use test data from a json file

[
  [
    {
      "name": "Brad"
    }
  ]
]

The data can automatically be converted to objects or primitive types.

class Person {
    String name;
}

@Test
@Parameters(source = "testData/json_object.json")
public void testAddJsonSource(Person obj) {
    Assert.assertNotNull(obj.name);
}

Maven integration

<dependency>
    <groupId>com.github.bradleywood</groupId>
    <artifactId>sqtf-core</artifactId>
    <version>1.1</version>
</dependency>

Configure the surefire plugin

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    <dependencies>
        <dependency>
            <groupId>com.github.bradleywood</groupId>
            <artifactId>sqtf-provider</artifactId>
            <version>1.1</version>
        </dependency>
    </dependencies>
</plugin>

Versions

Version
1.1
1.0