Skip to content

Instantly share code, notes, and snippets.

Avatar
🇧🇷

Elias Nogueira eliasnogueira

🇧🇷
View GitHub Profile
@eliasnogueira
eliasnogueira / mttjd.md
Created May 25, 2023 13:17
Modern Testing Tools for Java Developers - Project links
View mttjd.md
@eliasnogueira
eliasnogueira / SoftAssertionJunit5Test.java
Last active March 26, 2023 11:30
SoftAssertions: JUnit 5
View SoftAssertionJunit5Test.java
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class SoftAssertionJunit5Test {
@Test
void softAssertionUsingJUnit5() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
@eliasnogueira
eliasnogueira / SoftAssertionTest.java
Last active March 25, 2023 14:00
SoftAssertion: AssertJ
View SoftAssertionTest.java
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Test;
class SoftAssertionTest {
@Test
void softAssertionUsingAssertJ() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
SoftAssertions.assertSoftly(softly -> {
@eliasnogueira
eliasnogueira / HardAssertionTest.java
Last active March 25, 2023 14:01
HardAssertion: JUnit 5
View HardAssertionTest.java
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Test;
class HardAssertionTest {
@Test
void hardAssertion() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
assertThat(person.getName()).isNotBlank();
@eliasnogueira
eliasnogueira / SoftAssertTestNGTest.java
Created March 25, 2023 12:53
SoftAssertions: TestNG
View SoftAssertTestNGTest.java
public class SoftAssertTestNGTest {
@Test
public void testNGSoftAssertion() {
var person = Person.builder().name("John").phoneNumber(null).age(16).build();
SoftAssert softAssert = new SoftAssert();
softAssert.assertEquals(person.getName(), "John");
softAssert.assertNotNull(person.getPhoneNumber(), "Phone number cannot be null");
softAssert.assertEquals(person.getAge(), 25, "Age should be equal");
@eliasnogueira
eliasnogueira / AgeTest.java
Last active March 23, 2023 19:53
JUnit 5 - When to use @valuesource: test example
View AgeTest.java
class AgeTest {
@DisplayName("Valid ages")
@ParameterizedTest(name = "{0} is a valid age for the requirement 18 to 30")
@ValueSource(ints = {18, 19, 29, 30})
void validAges(int age) {
Assertions.assertThat(isAgeValid(age)).isTrue();
}
@eliasnogueira
eliasnogueira / Example.java
Created March 23, 2023 17:35
JUnit 5 - When to use @valuesource: code example
View Example.java
public class Example {
private Boolean isAgeValid(int age) {
return age >= 18 && age <= 30 ? Boolean.TRUE : Boolean.FALSE;
}
}
@eliasnogueira
eliasnogueira / modern_testing_tools.md
Last active June 2, 2023 19:13
Modern Testing Tools for Java Developers
View modern_testing_tools.md

Title

Modern Testing Tools for Java Developers

Description

We are, constantly, evolving the codebase by applying the best development practices, approaches, and design patterns. There's a lot of support from frameworks and libraries to do this during the SDLC.

New versions of the API framework appear, adding the last trending and here we go again: changing our code to adopt these new things. How awesome it is! We are improving!

How about one of the most important and, sometimes, missed things: quality! How the quality evolves within the adoption of new versions of development frameworks and libraries?

@eliasnogueira
eliasnogueira / service-container.yaml
Created January 2, 2023 18:30
Example of a service container
View service-container.yaml
jobs:
build:
runs-on: ubuntu-latest
services:
credit-api:
image: eliasnogueira/combined-credit-api:latest
ports:
- 8088:8088
@eliasnogueira
eliasnogueira / docker-compose.yml
Created November 25, 2022 16:00
[JavaAdvent] Docker compose file to copy the necessary Wiremock files and build the Docker image
View docker-compose.yml
version: '3.9'
services:
wiremock:
build:
context: ./
dockerfile: Dockerfile
image: wiremock-custom
container_name: wiremock-credit-restriction-api
ports: