Skip to content

Instantly share code, notes, and snippets.

View vepo's full-sized avatar
💻
/bin/bash

Victor Osório vepo

💻
/bin/bash
View GitHub Profile
<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>
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");
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);
public class TestExecutor {
public Result execute(Test test) {
test.setup();
test.execute();
test.tearDown();
}
}
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")
Suite UserTest {
Properties {
userContent: """
{
"id": 123,
"firstName": "John",
"lastName" : "Doe"
}"""
}
HTTP CreateUser {
userService.create(givenRandonUser())
assertThat(thenAllUsers()).hasSize(1);
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
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;
});
}
}
User user = new User();
user.setName(randomString());
user.setPassword(randomString());
userService.create(user)
List<User> allUsers = userService.list();
assertThat(allUsers).hasSize(1);