Skip to content

Commit

Permalink
Refatorando alguns teste para acelerar a execução na mesma instancia …
Browse files Browse the repository at this point in the history
…do browser
  • Loading branch information
orlando-dev committed Feb 3, 2021
1 parent 117cb19 commit 7f18c98
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 31 deletions.
13 changes: 0 additions & 13 deletions src/main/java/br/ce/orlando/core/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,16 @@

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

import br.ce.orlando.pages.LoginPage;

public class BaseTest {
private LoginPage page = new LoginPage();


@Rule
public TestName testName = new TestName();

@Before
public void inicializa() {
page.acessarTelaInicial();
page.setEmail("orlando@7");
page.setSenha("1234567");
page.entrar();
}

@After
public void finaliza() throws IOException{
TakesScreenshot ss = (TakesScreenshot) getDriver();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/br/ce/orlando/core/Propriedades.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

public class Propriedades {

public static boolean FECHAR_BROWSER = true;
public static boolean FECHAR_BROWSER = false;

public static Browsers browser = Browsers.CHROME;

public static String NOME_CONTA_ALTERADA = "Conta Alterada " + System.nanoTime();

public enum Browsers {
CHROME,
FIREFOX
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/br/ce/orlando/pages/MenuPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public void acessarTelaResumo() {
clicarLink("Resumo Mensal");
}

public void acessarTelaPrincipal() {
clicarLink("Home");
}
}
26 changes: 19 additions & 7 deletions src/main/java/br/ce/orlando/suites/SuiteGeral.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
package br.ce.orlando.suites;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

import br.ce.orlando.core.DriverFactory;
import br.ce.orlando.pages.LoginPage;
import br.ce.orlando.tests.ContaTest;
import br.ce.orlando.tests.MovimentacaoTest;
import br.ce.orlando.tests.RemoverMovimentacaoContaTest;
import br.ce.orlando.tests.ResumoTest;
import br.ce.orlando.tests.SaldoTest;

@RunWith(Suite.class)
@SuiteClasses({
ContaTest.class,
MovimentacaoTest.class,
RemoverMovimentacaoContaTest.class,
SaldoTest.class,
ResumoTest.class
})
@SuiteClasses({ ContaTest.class, MovimentacaoTest.class, RemoverMovimentacaoContaTest.class, SaldoTest.class,
ResumoTest.class })
public class SuiteGeral {
private static LoginPage page = new LoginPage();

@BeforeClass
public static void inicializa() {
page.acessarTelaInicial();
page.setEmail("orlando@7");
page.setSenha("1234567");
page.entrar();
}

@AfterClass
public static void finaliza() {
DriverFactory.killDriver();
}
}
5 changes: 3 additions & 2 deletions src/main/java/br/ce/orlando/tests/ContaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.runners.MethodSorters;

import br.ce.orlando.core.BaseTest;
import br.ce.orlando.core.Propriedades;
import br.ce.orlando.pages.ContasPage;
import br.ce.orlando.pages.MenuPage;

Expand All @@ -30,7 +31,7 @@ public void test2_AlterarConta() {
menuPage.acessarTelaListarConta();

contasPage.clicarAlterarConta("Conta do Teste");
contasPage.setNome("Conta do Teste alterada");
contasPage.setNome(Propriedades.NOME_CONTA_ALTERADA);
contasPage.salvar();

Assert.assertEquals("Conta alterada com sucesso!", contasPage.obterMensagemSucesso());
Expand All @@ -40,7 +41,7 @@ public void test2_AlterarConta() {
public void test3_InserirContaMesmoNome() {
menuPage.acessarTelaInserirConta();

contasPage.setNome("Conta do Teste alterada");
contasPage.setNome(Propriedades.NOME_CONTA_ALTERADA);
contasPage.salvar();

Assert.assertEquals("Já existe uma conta com esse nome!", contasPage.obterMensagemErro());
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/br/ce/orlando/tests/MovimentacaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.runners.MethodSorters;

import br.ce.orlando.core.BaseTest;
import br.ce.orlando.core.Propriedades;
import br.ce.orlando.pages.MenuPage;
import br.ce.orlando.pages.MovimentacaoPage;
import br.ce.orlando.utils.DataUtils;
Expand All @@ -30,7 +31,7 @@ public void test1_InserirMovimentacao() {
movPage.setDescricao("Movimentação do Teste");
movPage.setInteressado("Interessado Qualquer");
movPage.setValor("700");
movPage.setConta("Conta do Teste alterada");
movPage.setConta(Propriedades.NOME_CONTA_ALTERADA);
movPage.setStatusPago();
movPage.salvar();

Expand Down Expand Up @@ -69,7 +70,7 @@ public void test3_InserirMovimentacaoFutura() {
movPage.setDescricao("Movimentação do Teste");
movPage.setInteressado("Interessado Qualquer");
movPage.setValor("700");
movPage.setConta("Conta do Teste alterada");
movPage.setConta(Propriedades.NOME_CONTA_ALTERADA);
movPage.setStatusPago();
movPage.salvar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.Test;

import br.ce.orlando.core.BaseTest;
import br.ce.orlando.core.Propriedades;
import br.ce.orlando.pages.ContasPage;
import br.ce.orlando.pages.MenuPage;

Expand All @@ -15,7 +16,7 @@ public class RemoverMovimentacaoContaTest extends BaseTest{
public void testExcluirContaComMovimentacao() {
menuPage.acessarTelaListarConta();

contasPage.clicarExcluirConta("Conta do Teste alterada");
contasPage.clicarExcluirConta(Propriedades.NOME_CONTA_ALTERADA);

Assert.assertEquals("Conta em uso na movimentações", contasPage.obterMensagemErro());
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/br/ce/orlando/tests/SaldoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
import org.junit.Test;

import br.ce.orlando.core.BaseTest;
import br.ce.orlando.core.Propriedades;
import br.ce.orlando.pages.HomePage;
import br.ce.orlando.pages.MenuPage;

public class SaldoTest extends BaseTest {
HomePage page = new HomePage();



HomePage homePage = new HomePage();
MenuPage menuPage = new MenuPage();

@Test
public void testSaldoConta() {
Assert.assertEquals("700.00", page.obterSaldoConta("Conta do Teste alterada"));
menuPage.acessarTelaPrincipal();
Assert.assertEquals("700.00", homePage.obterSaldoConta(Propriedades.NOME_CONTA_ALTERADA));
}
}

0 comments on commit 7f18c98

Please sign in to comment.