Skip to content

Instantly share code, notes, and snippets.

🤖

Elias Nogueira eliasnogueira

🤖
View GitHub Profile
@eliasnogueira
eliasnogueira / .gitlab-ci.yml
Created Jun 16, 2020
Example of a pipeline script using GitLab CI
View .gitlab-ci.yml
image: markhobson/maven-chrome:jdk-11
stages:
- build
- test
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
cache:
@eliasnogueira
eliasnogueira / BeforeTestExecution.java
Created Jun 16, 2020
Code snippet showing the usage of WebDriverManager and a headless Google Chrome browser instantiation
View BeforeTestExecution.java
@BeforeAll
static void webdrivermanagerSetup() {
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
driver = new ChromeDriver(options);
driver.get("https://github.com/bonigarcia/webdrivermanager");
@eliasnogueira
eliasnogueira / ChromeHeadessSnippet.java
Created Jun 16, 2020
Code snippet to set the headless mode on Google Chrome test execution using the Selenium WebDriver Java library
View ChromeHeadessSnippet.java
ChromeOptions options = new ChromeOptions();
options.setHeadless(true)
@eliasnogueira
eliasnogueira / presentation1.md
Last active Jun 10, 2020
Expanding the API test coverage
View presentation1.md

Expanding the API test coverage

Description of the session

Are the unit tests of your team uncovering bugs before the user? Are you certain that your unit or integration tests will guarantee good coverage? Can you reproduce some end-to-end tests in your API? Given the last wave of adopted architectural changes on many backend systems, the best coverage in any aspect is necessary. Even though developers create integration or end-to-end tests in a REST endpoint there’re other testing techniques and levels to be applied to smash the bugs during the development process.

As Software Engineers, we’re concerned about to create the maximum test coverage for our API’s through unit and integration tests (shift-left test) using mocks to support a better strategy and removing dependencies. However, to have a great breadth of test coverage we need to think about more types of testing and, mainly, how can we execute them applied to a pipeline to deliver our APIs through a Continuous Delivery or Continuous Deployme

@eliasnogueira
eliasnogueira / AssertExamplesTest.java
Created Mar 16, 2020
Example showing different ways to assert a text
View AssertExamplesTest.java
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.Test;
public class AssertionTest {
public static final String ACTUAL = "text wrong here";
public static final String EXPECTED = "text right here";
View MyTestWithBaseTest.java
public class MyTestWithBaseTest extends BaseTest {
@Test
public void myTest() {
driver.get("http://eliasnogueira.com");
}
@BeforeMethod
@Override
View BassTest.java
public class BaseTest {
protected WebDriver driver;
@BeforeMethod
public void setup() {
WebDriverManager.getInstance(DriverManagerType.CHROME).setup();
driver = new ChromeDriver();
}
View LocalBrowserFactory.java
public class LocalDriverManager {
// to make this work just pass the browser name, that must match from the DriverManagerType class
public WebDriver createInstance(String browser) {
WebDriver driver = null;
try {
DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase());
Class<?> driverClass = Class.forName(driverManagerType.browserClass());
WebDriverManager.getInstance(driverManagerType).setup();
View WebDriverManagerInstance.java
import static io.github.bonigarcia.wdm.DriverManagerType.CHROME;
import org.openqa.selenium.WebDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
// ...
DriverManagerType chrome = DriverManagerType.CHROME;
WebDriverManager.getInstance(chrome).setup();
Class<?> chromeClass = Class.forName(chrome.browserClass());
View WebDriverManagerExample.java
public class ChromeTest {
public void openGoogleChrome() {
// setup the browsr binary and set the proper path
WebDriverManager.chromedriver().setup();
// create the Google Chrome browser instance
WebDriver driver = new ChromeDriver();
You can’t perform that action at this time.