Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathanmdr/method-chain-with-dsl-tests
Projeto utilizado na apresentação da palestra "Testes Além Do Código" na trilha Testes no TDC Connections 2022.
https://github.com/jonathanmdr/method-chain-with-dsl-tests
dsl java maven method-chaining tdc test
Last synced: 5 days ago
JSON representation
Projeto utilizado na apresentação da palestra "Testes Além Do Código" na trilha Testes no TDC Connections 2022.
- Host: GitHub
- URL: https://github.com/jonathanmdr/method-chain-with-dsl-tests
- Owner: jonathanmdr
- Created: 2022-03-23T00:36:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-02T19:23:17.000Z (4 months ago)
- Last Synced: 2024-10-17T00:19:15.244Z (20 days ago)
- Topics: dsl, java, maven, method-chaining, tdc, test
- Language: Java
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testes Além do Código
Projeto utilizado na apresentação da palestra "Testes Além Do Código" na trilha Testes no TDC Connections 2022.[![CI](https://github.com/jonathanmdr/method-chain-with-dsl-tests/actions/workflows/ci.yml/badge.svg)](https://github.com/jonathanmdr/method-chain-with-dsl-tests/actions/workflows/ci.yml)
[![CodeFactor](https://www.codefactor.io/repository/github/jonathanmdr/method-chain-with-dsl-tests/badge)](https://www.codefactor.io/repository/github/jonathanmdr/method-chain-with-dsl-tests)## Sobre o Projeto
O projeto consiste em uma pequena calculadora contendo as quatro operações básicas: `soma`, `subtração`, `multiplicação` e `divisão`.### Exemplo de teste tradicionalmente escrito:
```java
@Test
void shouldBeApplySum() {
OperationData operationData = OperationData.builder()
.firstNumber(10)
.secondNumber(10)
.build();BigDecimal actual = SUM.execute(operationData);
Assertions.assertThat(actual)
.usingComparator(BigDecimal::compareTo)
.isEqualTo(BigDecimal.valueOf(20));
}
```### Exemplo de teste utilizando DSL + Method Chaining:
```java
@Test
void shouldBeApplySumWithDsl() {
given()
.firstNumberEqualTo(10)
.secondNumberEqualTo(10)
.when(SUM::execute)
.then()
.assertResult()
.isEqualTo(20);
}
```### Exemplo com cenário de falha utilizando DSL + Method Chaining:
```java
@Test
void shouldBeThrownBusinessExceptionWhenApplyingDivisionByZero() {
given()
.firstNumberEqualTo(10)
.secondNumberEqualTo(0)
.when(DIVISION::execute)
.then()
.assertException()
.isInstanceOf(BusinessException.class)
.messageIsEqualTo("An unexpected error occurred");
}
```## Outros projetos com exemplos:
[Projeto: Java + Spring + JUnit + Mockito](https://github.com/jonathanmdr/DynamicDataSourceRouting)
[Projeto: Java + JUnit + Mockito + Generics](https://github.com/jonathanmdr/Shopping-Cart-TDD)