POJO Unit Test Utility

Collection of unit test utility classes to improve code coverage for POJO (Plain Old Java Object) classes

License

License

Categories

Categories

KeY Data Data Formats Formal Verification
GroupId

GroupId

com.github.publickey
ArtifactId

ArtifactId

pojo-test-utils
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

POJO Unit Test Utility
Collection of unit test utility classes to improve code coverage for POJO (Plain Old Java Object) classes
Project URL

Project URL

https://github.com/PublicKey/PublicKeyStore
Source Code Management

Source Code Management

https://github.com/PublicKey/pojo-test-utils.git

Download pojo-test-utils

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.publickey/pojo-test-utils/ -->
<dependency>
    <groupId>com.github.publickey</groupId>
    <artifactId>pojo-test-utils</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.publickey/pojo-test-utils/
implementation 'com.github.publickey:pojo-test-utils:1.0.0'
// https://jarcasting.com/artifacts/com.github.publickey/pojo-test-utils/
implementation ("com.github.publickey:pojo-test-utils:1.0.0")
'com.github.publickey:pojo-test-utils:jar:1.0.0'
<dependency org="com.github.publickey" name="pojo-test-utils" rev="1.0.0">
  <artifact name="pojo-test-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.publickey', module='pojo-test-utils', version='1.0.0')
)
libraryDependencies += "com.github.publickey" % "pojo-test-utils" % "1.0.0"
[com.github.publickey/pojo-test-utils "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

pojo-test-utils

Collection of unit test utility classes to improve code coverage for POJO (Plain Old Java Object) classes

Maven:

<dependency>
  <groupId>com.github.publickey</groupId>
  <artifactId>pojo-test-utils</artifactId>
  <version>1.0.0</version>
  <scope>test</scope>
</dependency>

Note: Library depends on: Java 1.8 JUnit 4.12

Components:

AbstractPojoTester - The main abstract base class meant to be extended by Unit Tests

Usage:

Here's an example of simple Pojo under test

import org.junit.Test;

import com.github.publickey.test.pojo.AbstractPojoTester;

public class MyPojoTest extends AbstractPojoTester {
    @Test
    public void testMyPojo() throws Exception {
        super.testPojoAllConstructors(MyPojo.class);
    }
}

Here's an example of simple Pojo under test

import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

import com.github.publickey.test.pojo.AbstractPojoTester;

public class MyPojo2Test extends AbstractPojoTester {
    @Before
    public void setUp() throws Exception {
        // set custom value of type String to be provided (i.e. MyPojo2 performs 
        // validation and requires the following format)
        super.putTestValue(String.class, "special-string");
    }

    @Test
    public void testMyPojo2() throws Exception {
        // perform standard POJO test on MyPojo2.class 
        // but also invoke someMethod and make sure no exception is thrown
        super.testPojo(MyPojo2.class, "someMethod");
    }
    
    @Test
    public void testMyPojo2CustomTest() throws Exception {
        // custom custom 
        MyPojo2 myPojo2 = new MyPojo2("Custom value");
        assertEquals("Custom value", myPojo2.calculate());
    }
}

The Maven artifacts are deployed with the Maven Repository Switchboard at: http://repo1.maven.org/maven2/com/github/publickey/pojo-test-utils/

Sample repository configuration

<repository>
	<id>central</id>
	<name>Maven Repository Switchboard</name>
	<layout>default</layout>
	<url>http://repo1.maven.org/maven2/</url>
	<snapshots>
		<enabled>false</enabled>
	</snapshots>
</repository>

The Maven artifacts are also avaialble through with Sonatype at: https://oss.sonatype.org/service/local/repositories/releases/content/

Versions

Version
1.0.0