Skip to content

authoronloadcode/Java-Unit-Tests-make-easy-Random-Values-with-Podam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java-Unit-Tests-make-easy-Random-Values-with-Podam

Java Unit Tests make easy Random Values with Podam

Introduction

In this article Java Unit Tests make easy - Random Values with PODAM, we discuss how to generate random values to object, collections we use on Junit test using PODAM library.

Full Article

Java Unit Tests make easy – Random Values with PODAM

Installation

Using PODAM in Spring boot application

We have to add podam dependencies to the spring boot project.

Please use the latest version. When I’m writing this article, the latest version is 7.2.5.RELEASE

For Maven

<dependency>
<groupId>uk.co.jemos.podam</groupId>
<artifactId>podam</artifactId>
<version>7.2.5.RELEASE</version>
<scope>test</scope>
</dependency>

For Gradle

testCompile group: 'uk.co.jemos.podam', name: 'podam', version: '7.2.5.RELEASE'

Sample usages

Pojo using podom

  @Test
void testFindAuthorByUserId() {
  PodamFactory factory = new PodamFactoryImpl();
  AuthorDoc authorDoc = factory.manufacturePojo(AuthorDoc.class);

  when(authorRepository.findById(anyLong())).thenReturn(authorDoc);

  AuthorDto result = authorService.findAuthorByUserId(Long.valueOf(1));
  Assertions.assertEquals(authorDoc.getUserId(), result.getUserId());
  Assertions.assertEquals(authorDoc.getFirstName(), result.getFirstName());
  Assertions.assertEquals(authorDoc.getBooks().size(), result.getBooks().size());
}

===========================================================================

Hi πŸ‘‹, I'm Maduka Jayawardana

I’m passionate about continuously learning and exploring new technologies, which will enhance my expertise status. Currently, I'm working as a Technical Lead.

comauthor

Connect with me:

comauthor madukaj @jaya-maduka

Languages and Tools:

angularjs aws azure bash chartjs docker elasticsearch figma firebase gcp git grafana heroku hive java javascript jenkins jest kafka kibana kubernetes laravel linux mariadb mongodb mysql nginx nodejs oracle postgresql postman python selenium spring travisci typescript vuejs

Support:

madukaj



About

Java Unit Tests make easy Random Values with Podam

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages