Skip to content

leverinfo/test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test Maven Central

This library helps to handle custom validations tests in Java.

Requirements

  • Java 1.8+

How to Use

To start, add that Maven dependency:

<dependency>
  <groupId>br.com.leverinfo</groupId>
  <artifactId>test</artifactId>
  <version>0.2.0</version>
</dependency>

or Gradle:

implementation 'br.com.leverinfo:test:0.2.0'

This must be use together with br.com.leverinfo:validation, so you need to import it as well:

Maven:

<dependency>
  <groupId>br.com.leverinfo</groupId>
  <artifactId>validation</artifactId>
  <version>0.4.0</version>
</dependency>

Gradle:

implementation 'br.com.leverinfo:validation:0.4.0'

Assuming that we have an example like the one described here...

...then, you can use it like this:

...
import br.com.leverinfo.test.ValidationAssertions;
...

public class FooTest {
  ...   
  public void testPrintName {
    ValidationAssertions.assertThatRequiredArgumentException()
      .isThrowingBy(() -> foo.printName(null))
      .withValidationMessage(MyMessages.NAME_REQUIRED);  
  }
}

Available Assertions

Below are the available assertions:

  • assertThatRequiredArgumentException - Asserts that a RequiredArgumentException was thrown
  • assertThatInvalidArgumentException - Asserts that a InvalidArgumentException was thrown
  • assertThatNotAllowedException - Asserts that a NotAllowedException was thrown
  • assertThatNotFoundException - Asserts that a NotFoundException was thrown
  • assertThatDependencyNotFoundException - Asserts that a DependencyNotFoundException was thrown
  • assertThatDuplicatedException - Asserts that a DuplicatedException was thrown

  • withValidationMessage - Validate if the thrown exception has expected ValidationMessage
  • withParams - Validate if the thrown exception has correct params

Roadmap

  • Create unit tests
  • Configure CI/CD pipeline

Your contribution is appreciated.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages