This file contains hidden or 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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>io.vepo.tests</groupId> | |
<artifactId>testsExample</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>testsExample</name> | |
<url>http://maven.apache.org</url> | |
<dependencies> |
This file contains hidden or 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
package io.vepo.tests; | |
import static org.junit.jupiter.api.Assertions.assertEquals; | |
import org.junit.jupiter.api.DisplayName; | |
import org.junit.jupiter.api.Test; | |
public class AppTest | |
{ | |
@Test | |
@DisplayName("Test if it works") | |
public void simpleTest() { | |
assertEquals("OK", "OK"); |
This file contains hidden or 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
public class SuiteExecutor { | |
public static void main(String[] args) { | |
TestExecutor executor = new TestExecutor(); | |
CompountTest test = CompondTest.create(new HttpTest(GET, "https://github.com/vepo"), | |
new ExtractTest("mailto:([^\"]+)\""), | |
new IsValidEmailTest()); | |
executor.setup(); | |
boolean result = executor.execute(); | |
executor.tearDown(); | |
System.out.println("User vepo has a valid email on his github profile? " + result); |
This file contains hidden or 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
public class TestExecutor { | |
public Result execute(Test test) { | |
test.setup(); | |
test.execute(); | |
test.tearDown(); | |
} | |
} |
This file contains hidden or 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
class UserTests { | |
@Test | |
@DisplayName("It SHOULD allow create Users without a name") | |
void createWithoutNameTest() { | |
// Do the tests | |
fail(); | |
} | |
@Test | |
@DisplayName("It SHOULD only requires username and password") |
This file contains hidden or 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
Suite UserTest { | |
Properties { | |
userContent: """ | |
{ | |
"id": 123, | |
"firstName": "John", | |
"lastName" : "Doe" | |
}""" | |
} | |
HTTP CreateUser { |
This file contains hidden or 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
userService.create(givenRandonUser()) | |
assertThat(thenAllUsers()).hasSize(1); |
This file contains hidden or 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
User user = givenUser(); | |
userService.createUser(user); // here I have 100% of Code Coverage | |
List<User> users = userService.list(); | |
assertThat(users).hasSize(1) // But I do not know if it was save | |
.allMatch(this::passwordIsEncrypted); // And if the password is correctly encrypted |
This file contains hidden or 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
public class SomeSingleton { | |
private static final instance AtomicReference<SomeSingleton> ref = new AtomicReference<>(); | |
public static SomeSingleton get() { | |
return instance.updateAndGet(e -> { | |
return isNull(e) ? new SomeSingleton() : e; | |
}); | |
} | |
} |
This file contains hidden or 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
User user = new User(); | |
user.setName(randomString()); | |
user.setPassword(randomString()); | |
userService.create(user) | |
List<User> allUsers = userService.list(); | |
assertThat(allUsers).hasSize(1); |