SlideShare a Scribd company logo
Tho Q Luong
Hanoi, June 28, 2014
2
๏‚จ Assuming listeners know:
๏‚ค Fundamentals of OOP
๏‚ค Basics of Java and PHP
๏‚จ Convention in this talk: when saying โ€œtestโ€
I mean โ€œtest automationโ€, โ€œautomated testโ€
(vs. manual test)
Before Outline
Outline
3
โ€ข Introduction
โ€ข Testing Framework: JUnit
โ€ข Best Practice to Implement Unit Test
โ€ข FAQ
โ€ข Conclusion
Introduction
4
๏‚จ Cool things that we were learnt in the school:
1. Algorithm and programming
2. UML and design
3. Test
4. Software project management
๏‚จ Must utilize all of them to create a good app?
Introduction
5
๏‚จ Definition of test automation:
โ€œTest automation is the use of special software to control
the execution of tests and the comparison of actual
outcomes with predicted outcomesโ€
6
test and me: a love story
Introduction
Test and me
7
๏‚จ Coding business services
๏‚จ Try my best but my code still
has serious errors
๏‚ค Developers in GUI layer
complain
๏‚ค Testers complain
๏‚ค And the world hates me
๏‚จ Q: How to let they know I
am a good developer ?
๏‚ค A: writing unit test
Business Service
GUI
Database
Three-tier application
Test and me: benefits of testing
8
๏‚จ Save my life
๏‚จ Improve product quality
๏‚จ Save my energy when:
๏‚ค Modify source code:
๏ฎ Maintain, upgrade
๏ฎ Fix bugs
๏‚ค Identify bugs
๏‚จ Avoid my silly and repetitive bugs
Testing Framework: JUnit
9
Testing Framework: JUnit
10
๏‚จ JUnit is an unit testing framework for Java
๏‚จ The most popular testing framework for Java
๏‚จ Ported to other languages: CPP, PHP, C#, Ruby,
Javascript โ€ฆ (21 languages)
๏‚จ Supported in IDEs: Netbeans, Eclipse
๏‚จ Simple and easy to use
Testing Framework: JUnit
11
Test Class
Test Result
Expected Outcome
Testing Framework: JUnit
12
๏‚จ Suite:
๏‚ค Group tests from many classes
๏‚ค Run test group as a single test execution
๏‚จ Category:
๏‚ค Group tests that are marked in sepecific classes
๏‚ค Run test group as a single test execution
JUnit summary
13
๏‚จ Keywords:
1. Assert.assertXXX()
2. @BeforeClass
3. @AfterClass
4. @Before
5. @After
6. @Test
7. Suite
8. Category
Best Practice
to
Implement Unit Test
14
Best Practice
15
๏‚จ 06 steps:
1. Identify test class, test method
example: to test UserService and AccessControlService:
create UserServiceTest with two method:
1. testUser(): CRUD and Find
2. testAccessControl(): assign, unassign and check permission
Best Practice
16
๏‚จ 06 steps:
2. Describe test
Best Practice
17
๏‚จ 06 steps: 3 + 4
3. Implement test: should prefix variables by step name
4. Join test into Single Test Category and run
Best Practice
18
๏‚จ 06 steps: 5 + 6
5. Create new suite or category if necessary
6. Join test into suitable suite(s) and/or category(s) and
run this suite(s) and/or category(s)
DEMO:
1. Single Test Category
2. Test Low Layer (Services)
3. Test High Layer (Controllers)
4. Load Test
----------
FAQ
19
FAQ
20
๏‚จ Q: what is test-driven development?
๏‚ค A: โ€œis a software development process that replies on
the repetion of very short development cycle:
1. Add a test
2. Run all tests and see if the new one fails
3. Write some code
4. Run tests
5. Refactor code
And repeatโ€
๏‚ค Related to the test-first programming concepts of XP
FAQ
21
๏‚จ Q: It is already 100K LOC, with no tests. Is it over?
๏‚ค A: NO, this is the good time to try writing tests
FAQ
22
๏‚จ Q: what is mock object?
๏‚ค A: Simulate objects that mimic behavior of real objects
๏‚ค Used in a unit test when real object is impracticial
๏‚จ Q: have you ever used a mock framework in test?
๏‚ค A: NO
๏‚จ Q: what are disadvantages of writing unit tests?
๏‚ค A: Slow down the release time
FAQ
23
๏‚จ Q: Do good developers not need to write test?
๏‚ค NO, because good developers will work with more
sophisticated projects
๏‚จ Q: Do good products have good tests and vice
versa?
๏‚ค Maybe YES
Conclusion
24
๏‚จ Test Automation lengthens coder life
and improves software quality
๏‚จ JUnit is easy to use
๏‚จ Let start writing unit test to build a better life!
Thank you!
25

More Related Content

What's hot (19)

PDF
Test driven development
lukaszkujawa
ย 
PPTX
Test-Driven Development
John Blum
ย 
PDF
Engaging IV&V Testing Services for Agile Projects
Ravi Kumar
ย 
PDF
Test Driven Development (TDD)
David Ehringer
ย 
PPTX
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
ย 
PPTX
Test driven development in .Net - 2010 + Eclipse
UTC Fire & Security
ย 
PPTX
Software Quality via Unit Testing
Shaun Abram
ย 
PPT
TDD (Test Driven Design)
nedirtv
ย 
PDF
Agile Programming Systems # TDD intro
Vitaliy Kulikov
ย 
DOCX
TestDrivenDeveloment
Antonio Tapper
ย 
PDF
Test Driven Development
Mireia Sangalo
ย 
PPTX
Unit Testing in Action - C#, NUnit, and Moq
XPDays
ย 
PDF
Android Devops : Master Continuous Integration and Delivery
mahmoud ramadan
ย 
PPTX
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove
ย 
PDF
Testing practicies not only in scala
Paweล‚ Panasewicz
ย 
PPTX
Test driven development
Nascenia IT
ย 
PPTX
Understanding Unit Testing
ikhwanhayat
ย 
PPTX
Unit Tests And Automated Testing
Lee Englestone
ย 
Test driven development
lukaszkujawa
ย 
Test-Driven Development
John Blum
ย 
Engaging IV&V Testing Services for Agile Projects
Ravi Kumar
ย 
Test Driven Development (TDD)
David Ehringer
ย 
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
ย 
Test driven development in .Net - 2010 + Eclipse
UTC Fire & Security
ย 
Software Quality via Unit Testing
Shaun Abram
ย 
TDD (Test Driven Design)
nedirtv
ย 
Agile Programming Systems # TDD intro
Vitaliy Kulikov
ย 
TestDrivenDeveloment
Antonio Tapper
ย 
Test Driven Development
Mireia Sangalo
ย 
Unit Testing in Action - C#, NUnit, and Moq
XPDays
ย 
Android Devops : Master Continuous Integration and Delivery
mahmoud ramadan
ย 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove
ย 
Testing practicies not only in scala
Paweล‚ Panasewicz
ย 
Test driven development
Nascenia IT
ย 
Understanding Unit Testing
ikhwanhayat
ย 
Unit Tests And Automated Testing
Lee Englestone
ย 

Similar to Introduction to test automation in java and php (20)

PPTX
Presentation sem 1.pptx
dendi65
ย 
DOCX
Test driven development and unit testing with examples in C++
Hong Le Van
ย 
PDF
SE2_Lec 21_ TDD and Junit
Amr E. Mohamed
ย 
PPTX
Unit Testing
Gian Maria Ricci
ย 
PDF
Unit testing (eng)
Anatoliy Okhotnikov
ย 
PPTX
DotNet unit testing training
Tom Tang
ย 
PPT
Junit Interview Questions-ppt
Mayank Kumar
ย 
PPTX
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
ย 
PPTX
Software Testing interview - Q&A and tips
Pankaj Dubey
ย 
PPTX
TDD - Agile
harinderpisces
ย 
PPTX
SE2018_Lec 20_ Test-Driven Development (TDD)
Amr E. Mohamed
ย 
PPTX
Software presentation
JennaPrengle
ย 
PPT
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
ย 
PPT
SE2011_10.ppt
MuhammedAlTijaniMrja
ย 
PPT
Google test training
Thierry Gayet
ย 
PPT
Test Driven Development
guestc8093a6
ย 
PPT
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
ย 
PPTX
Tools for Software Testing
Mohammed Moishin
ย 
PPTX
Test Driven Development
Sergey Aganezov
ย 
PPTX
Making the Unstable Stable - An Intro To Testing
Cameron Presley
ย 
Presentation sem 1.pptx
dendi65
ย 
Test driven development and unit testing with examples in C++
Hong Le Van
ย 
SE2_Lec 21_ TDD and Junit
Amr E. Mohamed
ย 
Unit Testing
Gian Maria Ricci
ย 
Unit testing (eng)
Anatoliy Okhotnikov
ย 
DotNet unit testing training
Tom Tang
ย 
Junit Interview Questions-ppt
Mayank Kumar
ย 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
ย 
Software Testing interview - Q&A and tips
Pankaj Dubey
ย 
TDD - Agile
harinderpisces
ย 
SE2018_Lec 20_ Test-Driven Development (TDD)
Amr E. Mohamed
ย 
Software presentation
JennaPrengle
ย 
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
ย 
SE2011_10.ppt
MuhammedAlTijaniMrja
ย 
Google test training
Thierry Gayet
ย 
Test Driven Development
guestc8093a6
ย 
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
ย 
Tools for Software Testing
Mohammed Moishin
ย 
Test Driven Development
Sergey Aganezov
ย 
Making the Unstable Stable - An Intro To Testing
Cameron Presley
ย 
Ad

Recently uploaded (20)

PDF
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
ย 
PPTX
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
ย 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
ย 
PDF
How DeepSeek Beats ChatGPT: Cost Comparison and Key Differences
sumitpurohit810
ย 
PPTX
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
ย 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
ย 
PDF
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
ย 
PPTX
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
ย 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeonยดs SAPPA P...
info969686
ย 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
PDF
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
PPTX
Seamless-Image-Conversion-From-Raster-to-wrt-rtx-rtx.pptx
Quick Conversion Services
ย 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
ย 
PPTX
declaration of Variables and constants.pptx
meemee7378
ย 
PDF
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
ย 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
PPTX
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
ย 
PDF
Code Once; Run Everywhere - A Beginnerโ€™s Journey with React Native
Hasitha Walpola
ย 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
ย 
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
ย 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
ย 
How DeepSeek Beats ChatGPT: Cost Comparison and Key Differences
sumitpurohit810
ย 
IObit Uninstaller Pro 14.3.1.8 Crack Free Download 2025
sdfger qwerty
ย 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
ย 
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
ย 
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
ย 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
ย 
Laboratory Workflows Digitalized and live in 90 days with Scifeonยดs SAPPA P...
info969686
ย 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
ย 
Seamless-Image-Conversion-From-Raster-to-wrt-rtx-rtx.pptx
Quick Conversion Services
ย 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
ย 
declaration of Variables and constants.pptx
meemee7378
ย 
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
ย 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
EO4EU Ocean Monitoring: Maritime Weather Routing Optimsation Use Case
EO4EU
ย 
Code Once; Run Everywhere - A Beginnerโ€™s Journey with React Native
Hasitha Walpola
ย 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 
Ad

Introduction to test automation in java and php

  • 1. Tho Q Luong Hanoi, June 28, 2014
  • 2. 2 ๏‚จ Assuming listeners know: ๏‚ค Fundamentals of OOP ๏‚ค Basics of Java and PHP ๏‚จ Convention in this talk: when saying โ€œtestโ€ I mean โ€œtest automationโ€, โ€œautomated testโ€ (vs. manual test) Before Outline
  • 3. Outline 3 โ€ข Introduction โ€ข Testing Framework: JUnit โ€ข Best Practice to Implement Unit Test โ€ข FAQ โ€ข Conclusion
  • 4. Introduction 4 ๏‚จ Cool things that we were learnt in the school: 1. Algorithm and programming 2. UML and design 3. Test 4. Software project management ๏‚จ Must utilize all of them to create a good app?
  • 5. Introduction 5 ๏‚จ Definition of test automation: โ€œTest automation is the use of special software to control the execution of tests and the comparison of actual outcomes with predicted outcomesโ€
  • 6. 6 test and me: a love story Introduction
  • 7. Test and me 7 ๏‚จ Coding business services ๏‚จ Try my best but my code still has serious errors ๏‚ค Developers in GUI layer complain ๏‚ค Testers complain ๏‚ค And the world hates me ๏‚จ Q: How to let they know I am a good developer ? ๏‚ค A: writing unit test Business Service GUI Database Three-tier application
  • 8. Test and me: benefits of testing 8 ๏‚จ Save my life ๏‚จ Improve product quality ๏‚จ Save my energy when: ๏‚ค Modify source code: ๏ฎ Maintain, upgrade ๏ฎ Fix bugs ๏‚ค Identify bugs ๏‚จ Avoid my silly and repetitive bugs
  • 10. Testing Framework: JUnit 10 ๏‚จ JUnit is an unit testing framework for Java ๏‚จ The most popular testing framework for Java ๏‚จ Ported to other languages: CPP, PHP, C#, Ruby, Javascript โ€ฆ (21 languages) ๏‚จ Supported in IDEs: Netbeans, Eclipse ๏‚จ Simple and easy to use
  • 11. Testing Framework: JUnit 11 Test Class Test Result Expected Outcome
  • 12. Testing Framework: JUnit 12 ๏‚จ Suite: ๏‚ค Group tests from many classes ๏‚ค Run test group as a single test execution ๏‚จ Category: ๏‚ค Group tests that are marked in sepecific classes ๏‚ค Run test group as a single test execution
  • 13. JUnit summary 13 ๏‚จ Keywords: 1. Assert.assertXXX() 2. @BeforeClass 3. @AfterClass 4. @Before 5. @After 6. @Test 7. Suite 8. Category
  • 15. Best Practice 15 ๏‚จ 06 steps: 1. Identify test class, test method example: to test UserService and AccessControlService: create UserServiceTest with two method: 1. testUser(): CRUD and Find 2. testAccessControl(): assign, unassign and check permission
  • 16. Best Practice 16 ๏‚จ 06 steps: 2. Describe test
  • 17. Best Practice 17 ๏‚จ 06 steps: 3 + 4 3. Implement test: should prefix variables by step name 4. Join test into Single Test Category and run
  • 18. Best Practice 18 ๏‚จ 06 steps: 5 + 6 5. Create new suite or category if necessary 6. Join test into suitable suite(s) and/or category(s) and run this suite(s) and/or category(s) DEMO: 1. Single Test Category 2. Test Low Layer (Services) 3. Test High Layer (Controllers) 4. Load Test ----------
  • 20. FAQ 20 ๏‚จ Q: what is test-driven development? ๏‚ค A: โ€œis a software development process that replies on the repetion of very short development cycle: 1. Add a test 2. Run all tests and see if the new one fails 3. Write some code 4. Run tests 5. Refactor code And repeatโ€ ๏‚ค Related to the test-first programming concepts of XP
  • 21. FAQ 21 ๏‚จ Q: It is already 100K LOC, with no tests. Is it over? ๏‚ค A: NO, this is the good time to try writing tests
  • 22. FAQ 22 ๏‚จ Q: what is mock object? ๏‚ค A: Simulate objects that mimic behavior of real objects ๏‚ค Used in a unit test when real object is impracticial ๏‚จ Q: have you ever used a mock framework in test? ๏‚ค A: NO ๏‚จ Q: what are disadvantages of writing unit tests? ๏‚ค A: Slow down the release time
  • 23. FAQ 23 ๏‚จ Q: Do good developers not need to write test? ๏‚ค NO, because good developers will work with more sophisticated projects ๏‚จ Q: Do good products have good tests and vice versa? ๏‚ค Maybe YES
  • 24. Conclusion 24 ๏‚จ Test Automation lengthens coder life and improves software quality ๏‚จ JUnit is easy to use ๏‚จ Let start writing unit test to build a better life!