SlideShare a Scribd company logo
1 of 22
Good practices on test automation
Gustavo Labbate Godoy
Where are test automation
on agile environments?
Several agile methodologies:
Scrum, Extreme Programming (XP), Lean Development, Feature-
Driven Development (FDD), Kanban, RUP and OpenUP.
Software Development by interactive and incremental way.
TDD, Data-Driven Testing, Regression Testing.
Automation is one of the three pilars of agile methodology.
Delivery on time, with all tested and approved.
“Working software is the primary measure of progress.”
(http://agilemanifesto.org)
Junit is unit test ?
What is unit test and
what is Junit ?
Unit test
Test the smaller of the components in a isolated way.
Test methods must be independent.
Functional test
Test the behavior of the sistem, from data inputs, processing and data
outputs.
assertEquals( ExpectedResult, returnProcessedData(entryData) );assertEquals( ExpectedResult, returnProcessedData(entryData) );
returnedObject = insertData(entryData);
assertNotNull(returnedObject); //Validating if insert was sucessfull
consultedObject = consultData(returnedObject);
assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through
system query
returnedObject = insertData(entryData);
assertNotNull(returnedObject); //Validating if insert was sucessfull
consultedObject = consultData(returnedObject);
assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through
system query
Correctly specify your tests
Correctly specify your tests
Don't say test, be more specific ...
TestCalculate - testCalc1 = shouldSumTwoInt
- testCalc2 = shouldSubtractFromSum
Test all functionality inside your method (avoid alphabetical ordering).
expectedObjects = testParameters;
expectedObjects = includeData(entryData);
assertNotNull(returnedObject); //Validating if insert was sucessfull
consultedObject = consultData(returnedObject);
assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through
system query
expectedObjects = testParameters;
expectedObjects = includeData(entryData);
assertNotNull(returnedObject); //Validating if insert was sucessfull
consultedObject = consultData(returnedObject);
assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through
system query
Correctly specify your tests
But ...
@Test
public void shouldSucessfulyInclude() { … }
@Test
public void shouldSucessfullyConsultAfterInclude() { … }
@Test
public void shouldSucessfulyInclude() { … }
@Test
public void shouldSucessfullyConsultAfterInclude() { … }
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Test
public void aShouldSucessfulyInclude() { … }
@Test
public void bShouldSucessfullyConsultAfterInclude() { … }
@Test
public void aShouldSucessfulyInclude() { … }
@Test
public void bShouldSucessfullyConsultAfterInclude() { … }
Alphabetically ordering methods:
Every test method must be independent.
Execution order is random.
Parameterize test data
Read from a spreadsheet (or another external file … )
@RunWith(Parameterized.class)
public Class UserInsert
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {{"ParameterA"}, {"ParameterB"}} );
}
public UserInsert(String[ ] parameters) { /* Add parameters to variables ... */ }
@RunWith(Parameterized.class)
public Class UserInsert
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {{"ParameterA"}, {"ParameterB"}} );
}
public UserInsert(String[ ] parameters) { /* Add parameters to variables ... */ }
https://bitbucket.org/wakaleo/jxlunit/src/6eb465c848c8/src/main/java/com/wakaleo/training/jxlunit/SpreadsheetData.java
@Parameters
public static Collection spreadSheetData() throws IOException {
InputStream spreadSheet = new FileInputStream(“mySheet.xls”);
return new SpreadSheetData(spreadSheet).getData();
}
@Parameters
public static Collection spreadSheetData() throws IOException {
InputStream spreadSheet = new FileInputStream(“mySheet.xls”);
return new SpreadSheetData(spreadSheet).getData();
}
Selenium
Selenium IDE or Core ?
IDE
• Record & Playback
• Export to several languages (C#, Java, Perl, PHP, Python, Ruby).
• In browser test execution.
• Code refactoring: Re-record your tests...
• To avoid: use plugins (do a little programming … )
• Record only on firefox, but run on others (the script, not in IDE … )
• Don't need advanced knowledge on exported code.
Core (coding)
• API to several languages (C#, Java, Perl, PHP, Python, Ruby).
• Build your own test framework, extending selenium.
• Test execution on several browser.
• Code refactoring: update only affected test code (Page Object Model)
• Knowledge of choosen language is essential.
Promote maintainability
Promote maintainability
Use fixtures
WebDriver driver
@BeforeClass
public static void runBeforeClass() throws Exception {
driver = new FirefoxDriver();
selenium = new WebDriverBackedSelenium(driver, url);
capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
}
@After
public void runAfterEachTest() {
printScreen();
}
@AfterClass
public static void runAfterClass() {
driver.quit();
}
WebDriver driver
@BeforeClass
public static void runBeforeClass() throws Exception {
driver = new FirefoxDriver();
selenium = new WebDriverBackedSelenium(driver, url);
capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
}
@After
public void runAfterEachTest() {
printScreen();
}
@AfterClass
public static void runAfterClass() {
driver.quit();
}
Promote maintainability
PageObjects
Object that represents a web system screen.
public Class LoginPO
@FindBy(id="user") WebElement user;
@FindBy(id="password") WebElement password;
@FindBy(id="btnClose") WebElement closeButton;
@FindBy(id="btnLogin") WebElement loginButton;
String userAcessApp = "automation";
String passwordAcessApp = "selenium";
public void typeAndEnter(String user, String pass)
{
usuer.sendKeys(user);
password.sendKeys(pass);
loginButton.click();
}
public Class LoginPO
@FindBy(id="user") WebElement user;
@FindBy(id="password") WebElement password;
@FindBy(id="btnClose") WebElement closeButton;
@FindBy(id="btnLogin") WebElement loginButton;
String userAcessApp = "automation";
String passwordAcessApp = "selenium";
public void typeAndEnter(String user, String pass)
{
usuer.sendKeys(user);
password.sendKeys(pass);
loginButton.click();
}
Organize …
Organize ...
Using Junit Test Suite
@RunWith(Suite.class)
@SuiteClasses({
TestClass1.class,
TestClass2.class,
TestClass3.class
})
public class AllMyTests
{
}
@RunWith(Suite.class)
@SuiteClasses({
TestClass1.class,
TestClass2.class,
TestClass3.class
})
public class AllMyTests
{
}
Solid foundations ...
Solid foundations ...
Guarantees data integrity
Spring's configuration:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${hibernate.connection.driver_class}" />
<property name="url" value="${hibernate.connection.url}" />
<property name="username" value="${hibernate.connection.username}" />
<property name="password" value="${hibernate.connection.password}" />
</bean>
Spring's configuration:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${hibernate.connection.driver_class}" />
<property name="url" value="${hibernate.connection.url}" />
<property name="username" value="${hibernate.connection.username}" />
<property name="password" value="${hibernate.connection.password}" />
</bean>
DBUnit's dataSet to setup and prepare a data base
<dataset>
<schema.USER LOGIN="User" PASSWORD="781b4ea1d8" NAME="Test User"
PASSWORD_EXPIRATION_DATE="2013-03-01 00:00:00.0" LOGIN_COUNT="0" EMAIL="user@test.com" />
</dataset>
DBUnit's dataSet to setup and prepare a data base
<dataset>
<schema.USER LOGIN="User" PASSWORD="781b4ea1d8" NAME="Test User"
PASSWORD_EXPIRATION_DATE="2013-03-01 00:00:00.0" LOGIN_COUNT="0" EMAIL="user@test.com" />
</dataset>
Orchestrate ...
Orchestrate ...
Manage automated executions
Orchestrate ...
Manage test execution results
References
Arquillian
http://arquillian.org/
Junit
http://junit.sourceforge.net/
Selenium
http://seleniumhq.org/
DBUnit
www.dbunit.org/
Page Objects
https://docs.jboss.org/author/display/ARQGRA2/Page+Objects
http://code.google.com/p/selenium/wiki/PageObjects
Jenkins
http://jenkins-ci.org/
TestLink
http://www.teamst.org/
Thanks!
gustavolabbate@gmail.com
linkedin.com/in/gustavolabbate
@gustavolabbate

More Related Content

What's hot

Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testingjeresig
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit TestPhuoc Bui
 
When assertthat(you).understandUnitTesting() fails
When assertthat(you).understandUnitTesting() failsWhen assertthat(you).understandUnitTesting() fails
When assertthat(you).understandUnitTesting() failsMartin Skurla
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript TestingKissy Team
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock FrameworkEugene Dvorkin
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
Sample Chapter of Practical Unit Testing with TestNG and Mockito
Sample Chapter of Practical Unit Testing with TestNG and MockitoSample Chapter of Practical Unit Testing with TestNG and Mockito
Sample Chapter of Practical Unit Testing with TestNG and MockitoTomek Kaczanowski
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsTomek Kaczanowski
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsTomek Kaczanowski
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJohn Ferguson Smart Limited
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification QuestionsSpringMockExams
 
Not your father's tests
Not your father's testsNot your father's tests
Not your father's testsSean P. Floyd
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Javaguy_davis
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first stepsRenato Primavera
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialAnup Singh
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic Peopledavismr
 

What's hot (20)

Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
Android Unit Test
Android Unit TestAndroid Unit Test
Android Unit Test
 
When assertthat(you).understandUnitTesting() fails
When assertthat(you).understandUnitTesting() failsWhen assertthat(you).understandUnitTesting() fails
When assertthat(you).understandUnitTesting() fails
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
Django Testing
Django TestingDjango Testing
Django Testing
 
Sample Chapter of Practical Unit Testing with TestNG and Mockito
Sample Chapter of Practical Unit Testing with TestNG and MockitoSample Chapter of Practical Unit Testing with TestNG and Mockito
Sample Chapter of Practical Unit Testing with TestNG and Mockito
 
Introduzione al TDD
Introduzione al TDDIntroduzione al TDD
Introduzione al TDD
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
3 j unit
3 j unit3 j unit
3 j unit
 
Confitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good TestsConfitura 2012 Bad Tests, Good Tests
Confitura 2012 Bad Tests, Good Tests
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit Tests
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification Questions
 
Not your father's tests
Not your father's testsNot your father's tests
Not your father's tests
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
 
Junit With Eclipse
Junit With EclipseJunit With Eclipse
Junit With Eclipse
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
 

Similar to Good Practices On Test Automation

Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developersAnton Udovychenko
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionpCloudy
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringromanovfedor
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingAnna Khabibullina
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnitMindfire Solutions
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentAll Things Open
 
An introduction to Test Driven Development on MapReduce
An introduction to Test Driven Development on MapReduceAn introduction to Test Driven Development on MapReduce
An introduction to Test Driven Development on MapReduceAnanth PackkilDurai
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 

Similar to Good Practices On Test Automation (20)

Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Appium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation ExecutionAppium TestNG Framework and Multi-Device Automation Execution
Appium TestNG Framework and Multi-Device Automation Execution
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
S313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discoveringS313352 optimizing java device testing with automatic feature discovering
S313352 optimizing java device testing with automatic feature discovering
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testing
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnit
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
Mxunit
MxunitMxunit
Mxunit
 
Unit testing
Unit testingUnit testing
Unit testing
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
An introduction to Test Driven Development on MapReduce
An introduction to Test Driven Development on MapReduceAn introduction to Test Driven Development on MapReduce
An introduction to Test Driven Development on MapReduce
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 

Recently uploaded

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Good Practices On Test Automation

  • 1. Good practices on test automation Gustavo Labbate Godoy
  • 2. Where are test automation on agile environments? Several agile methodologies: Scrum, Extreme Programming (XP), Lean Development, Feature- Driven Development (FDD), Kanban, RUP and OpenUP. Software Development by interactive and incremental way. TDD, Data-Driven Testing, Regression Testing. Automation is one of the three pilars of agile methodology. Delivery on time, with all tested and approved. “Working software is the primary measure of progress.” (http://agilemanifesto.org)
  • 3. Junit is unit test ?
  • 4. What is unit test and what is Junit ? Unit test Test the smaller of the components in a isolated way. Test methods must be independent. Functional test Test the behavior of the sistem, from data inputs, processing and data outputs. assertEquals( ExpectedResult, returnProcessedData(entryData) );assertEquals( ExpectedResult, returnProcessedData(entryData) ); returnedObject = insertData(entryData); assertNotNull(returnedObject); //Validating if insert was sucessfull consultedObject = consultData(returnedObject); assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through system query returnedObject = insertData(entryData); assertNotNull(returnedObject); //Validating if insert was sucessfull consultedObject = consultData(returnedObject); assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through system query
  • 6. Correctly specify your tests Don't say test, be more specific ... TestCalculate - testCalc1 = shouldSumTwoInt - testCalc2 = shouldSubtractFromSum Test all functionality inside your method (avoid alphabetical ordering). expectedObjects = testParameters; expectedObjects = includeData(entryData); assertNotNull(returnedObject); //Validating if insert was sucessfull consultedObject = consultData(returnedObject); assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through system query expectedObjects = testParameters; expectedObjects = includeData(entryData); assertNotNull(returnedObject); //Validating if insert was sucessfull consultedObject = consultData(returnedObject); assertEquals( consultedObject, expectedObject ); //Validating if insert was sucessfull through system query
  • 7. Correctly specify your tests But ... @Test public void shouldSucessfulyInclude() { … } @Test public void shouldSucessfullyConsultAfterInclude() { … } @Test public void shouldSucessfulyInclude() { … } @Test public void shouldSucessfullyConsultAfterInclude() { … } @FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Test public void aShouldSucessfulyInclude() { … } @Test public void bShouldSucessfullyConsultAfterInclude() { … } @Test public void aShouldSucessfulyInclude() { … } @Test public void bShouldSucessfullyConsultAfterInclude() { … } Alphabetically ordering methods: Every test method must be independent. Execution order is random.
  • 8. Parameterize test data Read from a spreadsheet (or another external file … ) @RunWith(Parameterized.class) public Class UserInsert @Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{"ParameterA"}, {"ParameterB"}} ); } public UserInsert(String[ ] parameters) { /* Add parameters to variables ... */ } @RunWith(Parameterized.class) public Class UserInsert @Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{"ParameterA"}, {"ParameterB"}} ); } public UserInsert(String[ ] parameters) { /* Add parameters to variables ... */ } https://bitbucket.org/wakaleo/jxlunit/src/6eb465c848c8/src/main/java/com/wakaleo/training/jxlunit/SpreadsheetData.java @Parameters public static Collection spreadSheetData() throws IOException { InputStream spreadSheet = new FileInputStream(“mySheet.xls”); return new SpreadSheetData(spreadSheet).getData(); } @Parameters public static Collection spreadSheetData() throws IOException { InputStream spreadSheet = new FileInputStream(“mySheet.xls”); return new SpreadSheetData(spreadSheet).getData(); }
  • 10. Selenium IDE or Core ? IDE • Record & Playback • Export to several languages (C#, Java, Perl, PHP, Python, Ruby). • In browser test execution. • Code refactoring: Re-record your tests... • To avoid: use plugins (do a little programming … ) • Record only on firefox, but run on others (the script, not in IDE … ) • Don't need advanced knowledge on exported code. Core (coding) • API to several languages (C#, Java, Perl, PHP, Python, Ruby). • Build your own test framework, extending selenium. • Test execution on several browser. • Code refactoring: update only affected test code (Page Object Model) • Knowledge of choosen language is essential.
  • 12. Promote maintainability Use fixtures WebDriver driver @BeforeClass public static void runBeforeClass() throws Exception { driver = new FirefoxDriver(); selenium = new WebDriverBackedSelenium(driver, url); capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true); } @After public void runAfterEachTest() { printScreen(); } @AfterClass public static void runAfterClass() { driver.quit(); } WebDriver driver @BeforeClass public static void runBeforeClass() throws Exception { driver = new FirefoxDriver(); selenium = new WebDriverBackedSelenium(driver, url); capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true); } @After public void runAfterEachTest() { printScreen(); } @AfterClass public static void runAfterClass() { driver.quit(); }
  • 13. Promote maintainability PageObjects Object that represents a web system screen. public Class LoginPO @FindBy(id="user") WebElement user; @FindBy(id="password") WebElement password; @FindBy(id="btnClose") WebElement closeButton; @FindBy(id="btnLogin") WebElement loginButton; String userAcessApp = "automation"; String passwordAcessApp = "selenium"; public void typeAndEnter(String user, String pass) { usuer.sendKeys(user); password.sendKeys(pass); loginButton.click(); } public Class LoginPO @FindBy(id="user") WebElement user; @FindBy(id="password") WebElement password; @FindBy(id="btnClose") WebElement closeButton; @FindBy(id="btnLogin") WebElement loginButton; String userAcessApp = "automation"; String passwordAcessApp = "selenium"; public void typeAndEnter(String user, String pass) { usuer.sendKeys(user); password.sendKeys(pass); loginButton.click(); }
  • 15. Organize ... Using Junit Test Suite @RunWith(Suite.class) @SuiteClasses({ TestClass1.class, TestClass2.class, TestClass3.class }) public class AllMyTests { } @RunWith(Suite.class) @SuiteClasses({ TestClass1.class, TestClass2.class, TestClass3.class }) public class AllMyTests { }
  • 17. Solid foundations ... Guarantees data integrity Spring's configuration: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${hibernate.connection.driver_class}" /> <property name="url" value="${hibernate.connection.url}" /> <property name="username" value="${hibernate.connection.username}" /> <property name="password" value="${hibernate.connection.password}" /> </bean> Spring's configuration: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${hibernate.connection.driver_class}" /> <property name="url" value="${hibernate.connection.url}" /> <property name="username" value="${hibernate.connection.username}" /> <property name="password" value="${hibernate.connection.password}" /> </bean> DBUnit's dataSet to setup and prepare a data base <dataset> <schema.USER LOGIN="User" PASSWORD="781b4ea1d8" NAME="Test User" PASSWORD_EXPIRATION_DATE="2013-03-01 00:00:00.0" LOGIN_COUNT="0" EMAIL="user@test.com" /> </dataset> DBUnit's dataSet to setup and prepare a data base <dataset> <schema.USER LOGIN="User" PASSWORD="781b4ea1d8" NAME="Test User" PASSWORD_EXPIRATION_DATE="2013-03-01 00:00:00.0" LOGIN_COUNT="0" EMAIL="user@test.com" /> </dataset>
  • 20. Orchestrate ... Manage test execution results