https://github.com/bradleywood/software-quality-test-framework
basic software test framework
https://github.com/bradleywood/software-quality-test-framework
java test-framework testing
Last synced: 2 months ago
JSON representation
basic software test framework
- Host: GitHub
- URL: https://github.com/bradleywood/software-quality-test-framework
- Owner: BradleyWood
- License: mit
- Created: 2018-02-15T18:04:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-08T00:12:18.000Z (almost 7 years ago)
- Last Synced: 2025-03-02T12:52:02.711Z (3 months ago)
- Topics: java, test-framework, testing
- Language: Java
- Size: 140 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```java
@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
```java
@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
```java
@Test
@Parameters(source = "dataGenerator")
public void parameterizedAdd(int a, int b, int expected) {
Assert.assertEquals(expected, a + b);
}public Collection dataGenerator() {
List 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
```json
[
[
{
"name": "Brad"
}
]
]
```The data can automatically be converted to objects or primitive types.
```java
class Person {
String name;
}@Test
@Parameters(source = "testData/json_object.json")
public void testAddJsonSource(Person obj) {
Assert.assertNotNull(obj.name);
}
```## Maven integration
```xml
com.github.bradleywood
sqtf-core
1.1```
Configure the surefire plugin
```xml
maven-surefire-plugin
2.20.1
com.github.bradleywood
sqtf-provider
1.1
```