Skip to content

Instantly share code, notes, and snippets.

View eliasnogueira's full-sized avatar
🇧🇷

Elias Nogueira eliasnogueira

🇧🇷
View GitHub Profile

Enhancing Project Integrity: A Modernization for Bug-Free Code

Description

Embarking on a Java project involves employing the best strategies, patterns, and architectural decisions, all geared towards a customer-centric.

Yet, there exists an often overlooked facet: quality assurance. While not entirely disregarded, we, as developers, sometimes limit ourselves to performing the basic unity and integration tests, which may leave room for bugs.

Fortunately, there are several straightforward approaches and tools that can be implemented to deliver a bug-free project with minimal effort.

@eliasnogueira
eliasnogueira / modern_testing_tools.md
Last active September 6, 2023 14:51
Modern Testing Tools for Java Developers

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 but missed items: quality! matchestalk will show you 5 libraries you, as a Java Developer, to improve the application quality with real-world examples.

class MethodSourceCase3ExampleTest {
@DisplayName("Unpronounceable entity tests")
@ParameterizedTest(name = "The Simulation {0} shows the error {1}")
@MethodSource("expensiveProducts")
void edgeCases(Simulation simulation, String errorMessage) {
Response response = postSimulation(simulation);
assertThat(response.statusCode).isEqualTo(422);
assertThat(response.body().errorMessage()).isEqualsTo(errorMessage);
class MethodSourceCase2ExampleTest {
@DisplayName("Payment status")
@ParameterizedTest(name = "The payment with status {0} returns the message {1}")
@MethodSource("statusList")
void paymentStatus(Status status, String message) {
String auditedPayment = auditService.getPayments(status);
assertThat(status).isEqualTo(message);
}
@eliasnogueira
eliasnogueira / ValueSourceSimpleExample.java
Created June 15, 2023 20:00
Simple example that explain how the MethodSource annotation from JUnit 5 works
class MyTestClass {
@DisplayName("Date must be from the current year")
@ParameterizedTest(name = "Check the current year of {0}")
@MethodSource("dateList")
void myTest(LocalDate date) {
assertThat(date).hasYear(2023);
}
static Stream<Arguments> dateList() {
@eliasnogueira
eliasnogueira / good-testing-practices-open-source-talk.md
Created June 11, 2023 14:32
Good testing practices in an open-source project

Title

Good testing practices in an open-source project

Description

Nowadays the contribution guide in every open-source project is not sufficient to describe the approaches, techniques, and how people solve break changes.

We all know: they are the most democratic projects we can work on, but sometimes not follow basic practices to elevate the project quality.

@eliasnogueira
eliasnogueira / SoftAssertionJunit5Test.java
Last active March 26, 2023 11:30
SoftAssertions: JUnit 5
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 / HardAssertionTest.java
Last active March 25, 2023 14:01
HardAssertion: JUnit 5
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 / SoftAssertionTest.java
Last active March 25, 2023 14:00
SoftAssertion: AssertJ
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 / SoftAssertTestNGTest.java
Created March 25, 2023 12:53
SoftAssertions: TestNG
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");