-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fim Curso: Testes Unitários Com JUnit
- Loading branch information
Showing
28 changed files
with
964 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.01 MB
Java/Testes-Unitarios-com-JUnit/Testes-Unitários-Com-JUnit-Willyan-Guimaraes-DIO.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Instrutor: Willyan Caetano. | ||
|
||
|
||
Testes Unitários com JUnit | ||
|
||
|
||
Apresentação do Curso | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Por que escrever Testes Unitários? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World, JUnit! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Aprofundando nos Recursos | ||
|
||
O básico para testar | ||
Mais algumas asserções | ||
After e Before | ||
Assumptions e Testes condicionais | ||
Testando exceptions | ||
Ordenando testes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Recursos de Testes nas IDEs | ||
|
||
Visual Studio Code | ||
Eclipse | ||
IntelliJ IDEA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Boas Práticas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Conclusão do Curso |
84 changes: 84 additions & 0 deletions
84
Java/Testes-Unitarios-com-JUnit/junit5-exemplos/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
############################# | ||
## Java | ||
############################## | ||
.mtj.tmp/ | ||
*.class | ||
*.jar | ||
*.war | ||
*.ear | ||
*.nar | ||
hs_err_pid* | ||
|
||
############################## | ||
## Maven | ||
############################## | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
pom.xml.bak | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
.mvn/wrapper/maven-wrapper.jar | ||
|
||
############################## | ||
## Gradle | ||
############################## | ||
bin/ | ||
build/ | ||
.gradle | ||
.gradletasknamecache | ||
gradle-app.setting | ||
!gradle-wrapper.jar | ||
|
||
############################## | ||
## IntelliJ | ||
############################## | ||
out/ | ||
.idea/ | ||
.idea_modules/ | ||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
############################## | ||
## Eclipse | ||
############################## | ||
.settings/ | ||
bin/ | ||
tmp/ | ||
.metadata | ||
.classpath | ||
.project | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.loadpath | ||
.factorypath | ||
|
||
############################## | ||
## NetBeans | ||
############################## | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
############################## | ||
## Visual Studio Code | ||
############################## | ||
.vscode/ | ||
.code-workspace | ||
|
||
############################## | ||
## OS X | ||
############################## | ||
.DS_Store |
31 changes: 31 additions & 0 deletions
31
Java/Testes-Unitarios-com-JUnit/junit5-exemplos/CONFIGURACAO.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
# Configurando JUnit | ||
|
||
## Maven | ||
|
||
Adicionar no `pom.xml` do projeto a dependência abaixo: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit.jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
## Gradle | ||
|
||
Adicionar ao arquivo `build.gradle` `testImplementation` no closure `dependencies` e `useJUnitPlatform()` no closure `test`, ficando mais ou menos assim. | ||
|
||
```groovy | ||
dependencies { | ||
//demais dependências do projeto | ||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2' | ||
} | ||
test { | ||
useJUnitPlatform() | ||
} | ||
``` | ||
|
||
Observação: A versão escolhida acima, `5.8.2`, escolhida nos exemplos, era a mais recente até o momento deste manual. Verificar versão mais nova em [Maven Repository](https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Willyan Guimarães Caetano | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# Testes unitários com JUnit | ||
|
||
Respositório com roteiros e exemplos de como utilizar JUnit no seu dia a dia como dev. | ||
Foi utilizado para os exemplos a versão 5.8.2, mais atual até o momento (29/01/2022). | ||
|
||
## Roteiros | ||
|
||
1. [Configurando JUnit](CONFIGURACAO.md) | ||
|
112 changes: 112 additions & 0 deletions
112
Java/Testes-Unitarios-com-JUnit/junit5-exemplos/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
<name>junit5-exemplos</name> | ||
<artifactId>junit5-exemplos</artifactId> | ||
<groupId>one.digitalinnovation</groupId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<description>Repositório com exemplos utilizando JUnit 5</description> | ||
|
||
<url>https://github.com/willyancaetano/junit5-exemplos</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT</name> | ||
<url>https://spdx.org/licenses/MIT.html</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<organization> | ||
<name>Digital Innovation One</name> | ||
<url>https://digitalinnovation.one</url> | ||
</organization> | ||
|
||
<scm> | ||
<url>https://github.com/willyancaetano/junit5-exemplos</url> | ||
<connection>[email protected]:willyancaetano/junit5-exemplos.git</connection> | ||
<developerConnection>[email protected]:willyancaetano/junit5-exemplos.git</developerConnection> | ||
</scm> | ||
|
||
<issueManagement> | ||
<system>Issues</system> | ||
<url>https://github.com/willyancaetano/junit5-exemplos/issues</url> | ||
</issueManagement> | ||
|
||
<ciManagement> | ||
<system>Pipelines</system> | ||
<url>https://github.com/willyancaetano/junit5-exemplos/pipelines</url> | ||
</ciManagement> | ||
|
||
<developers> | ||
<developer> | ||
<id>willyancaetano</id> | ||
<email>[email protected]</email> | ||
<name>Willyan Guimarães Caetano</name> | ||
<organization>Digital Innovation One</organization> | ||
<organizationUrl>https://digitalinnovation.one</organizationUrl> | ||
<roles> | ||
<role>architect</role> | ||
<role>developer</role> | ||
</roles> | ||
<timezone>America/Sao_Paulo</timezone> | ||
</developer> | ||
</developers> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<main.class>one.digitalinnovation.junit.HelloWorld</main.class> | ||
<java.version>11</java.version> | ||
<junit.jupiter.version>5.8.0</junit.jupiter.version> | ||
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version> | ||
<maven.jar.plugin.version>3.1.1</maven.jar.plugin.version> | ||
<maven.surefire.plugin.version>2.22.1</maven.surefire.plugin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit.jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven.compiler.plugin.version}</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
<showWarnings>true</showWarnings> | ||
<showDeprecation>true</showDeprecation> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>${maven.jar.plugin.version}</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<classpathPrefix>lib/</classpathPrefix> | ||
<mainClass>${main.class}</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven.surefire.plugin.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
53 changes: 53 additions & 0 deletions
53
...tarios-com-JUnit/junit5-exemplos/src/main/java/com/github/willyancaetano/junit/Conta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2022 Willyan Guimarães Caetano | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
package com.github.willyancaetano.junit; | ||
|
||
public class Conta { | ||
|
||
private String numeroConta; | ||
|
||
private int saldo; | ||
|
||
public Conta(String numeroConta, int saldo) { | ||
this.numeroConta = numeroConta; | ||
this.saldo = saldo; | ||
} | ||
|
||
public String getNumeroConta() { | ||
return numeroConta; | ||
} | ||
|
||
public int getSaldo() { | ||
return saldo; | ||
} | ||
|
||
public void lancaCredito(int valor) { | ||
this.saldo += valor; | ||
} | ||
|
||
public void lancaDebito(int valor) { | ||
this.saldo -= valor; | ||
} | ||
} |
Oops, something went wrong.