Skip to content

Instantly share code, notes, and snippets.

View luuizeduardo's full-sized avatar

Luiz Eduardo Martins luuizeduardo

View GitHub Profile
@luuizeduardo
luuizeduardo / workflow.yaml
Last active February 10, 2023 16:53
Initial workflow file
name: Java CI with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
@luuizeduardo
luuizeduardo / allure-pom.xml
Last active February 10, 2023 12:20
POM file with Allure Report
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
package org.example.services;
import com.fasterxml.jackson.databind.JsonNode;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
package org.example.repositories;
import com.fasterxml.jackson.databind.JsonNode;
import io.restassured.response.Response;
import org.json.JSONException;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.stereotype.Repository;
@Repository
{
"name": "Luiz Eduardo",
"job": "Senior QA Engineer"
}
@luuizeduardo
luuizeduardo / ApiTestV2
Last active October 21, 2022 15:55
Improve the object mapping
package api.test.java.tests;
import com.fasterxml.jackson.databind.JsonNode;
import io.restassured.response.Response;
import org.example.repositories.FileUtils;
import org.example.services.YourApiService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
package org.example.repositories;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.net.URL;
@Repository
@luuizeduardo
luuizeduardo / TestCase
Created October 7, 2022 16:13
Create user test case
@Test
public void testCreateUser() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String body = "{\"name\": \"Luiz Eduardo\", \"job\": \"Senior QA Engineer\"}";
JsonNode requestBody = mapper.readTree(body);
}
@luuizeduardo
luuizeduardo / ApiTestConstructor
Created October 7, 2022 15:38
Constructor method
private final YourApiService yourApiService;
public ApiTest(YourApiService yourApiService) {
this.yourApiService = yourApiService;
}