SlideShare a Scribd company logo
Testing basics for developers
Anton Udovychenko
1 1 / 2 0 1 3
Agenda
• Motivation
• Unit testing
• JUnit, Mockito, Hamcrest, JsTestDriver
• Integration testing
• Persistence testing, Arquillian
• Functional testing
• SoapUI, Selenium
• Q&A
Why should we care?
Automated testing
Functional
Integration
Unit
5%
15%
80%
Unit testing
Test small portions of production code
Confidence to change
Quick Feedback
Documentation
Functional
Integration
Unit
Unit testing
TestNG
JUnit lifecycle
1. @BeforeClass
2. For each @Test
a) Instanciate test class
b) @Before
c) Invoke the test
d) @After
3. @AfterClass
JUnit advanced
1. @Rule and @ClassRule
2. Parametrized
3. Mocks
4. Hamcrest
JUnit @Rule
public class MyRule implements TestRule {
@Override
public Statement apply( Statement base, Description description ) {
return new MyStatement( base );
}
}
JUnit @Rule
public class MyStatement extends Statement {
private final Statement base;
public MyStatement( Statement base ) {
this.base = base;
}
@Override
public void evaluate() throws Throwable {
System.out.println( "before" );
try {
base.evaluate();
} finally {
System.out.println( "after" );
}
}
}
public class MyRule implements TestRule {
@Override
public Statement apply( Statement base, Description description ) {
return new MyStatement( base );
}
}
JUnit @Rule
public class MyTest {
@Rule
public MyRule myRule = new MyRule();
@Test
public void testRun() {
System.out.println( "during" );
}
}
public class MyRule implements TestRule {
@Override
public Statement apply( Statement base, Description description ) {
return new MyStatement( base );
}
}
public class MyStatement extends Statement {
private final Statement base;
public MyStatement( Statement base ) {
this.base = base;
}
@Override
public void evaluate() throws Throwable {
System.out.println( "before" );
try {
base.evaluate();
} finally {
System.out.println( "after" );
}
}
}
JUnit @Rule
public class MyTest {
@Rule
public MyRule myRule = new MyRule();
@Test
public void testRun() {
System.out.println( "during" );
}
}
public class MyRule implements TestRule {
@Override
public Statement apply( Statement base, Description description ) {
return new MyStatement( base );
}
}
public class MyStatement extends Statement {
private final Statement base;
public MyStatement( Statement base ) {
this.base = base;
}
@Override
public void evaluate() throws Throwable {
System.out.println( "before" );
try {
base.evaluate();
} finally {
System.out.println( "after" );
}
}
}
Output:
before
during
after
JUnit @ClassRule
@RunWith(Suite.class)
@SuiteClasses({ TestCase1.class, TestCase2.class })
public class AllTests {
@ClassRule
public static Timeout timeout = new Timeout(3000);
}
JUnit Parametrized
@RunWith(value = Parameterized.class)
public class MyTest {
private int number;
public MyTest(int number) {
this.number = number;
}
@Parameters
public static Collection<Object[]> data() {
Object[][] data = new Object[][] { { 1 }, { 2 }, { 3 }, { 4 } };
return Arrays.asList(data);
}
@Test
public void pushTest() {
System.out.println("Parameterized Number is : " + number);
}
}
Mockito
Mockito is a mocking framework for unit tests in Java
Mockito
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import java.util.Iterator;
import org.junit.Test;
....
@Test
public void iteratorWillReturnHelloWorld(){
//arrange
Iterator i=mock(Iterator.class);
when(i.next()).thenReturn("Hello").thenReturn("World");
//act
String result=i.next()+" "+i.next();
//assert
assertEquals("Hello World", result);
}
Hamcrest
Hamcrest is a matchers framework that assists writing software tests
Hamcrest
assertTrue(foo.contains("someValue") && foo.contains("anotherValue"));
Hamcrest
assertTrue(foo.contains("someValue") && foo.contains("anotherValue"));
assertThat(foo, hasItems("someValue", "anotherValue"));
vs
Hamcrest
assertTrue(foo.contains("someValue") && foo.contains("anotherValue"));
assertThat(foo, hasItems("someValue", "anotherValue"));
vs
assertThat(
table,
column("Type",contains("A","B","C")).where(cell("Status", is("Ok")))
);
Another example:
JsTestDriver
JsTestDriver is an open source JavaScript unit tests runner
JsTestDriver
Integration testing
Test collaboration between components
Database
IO system
Special environment configuration
Functional
Integration
Unit
Persistence testing
In memory databases
DBUnit
Arquillian
Arquillian is a platform that simplifies integration testing for Java middleware
Arquillian
• Real Tests (no mocks)
Arquillian
• Real Tests (no mocks)
• IDE Friendly
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
• Classpath Control
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
• Classpath Control
• Drive the Browser
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
• Classpath Control
• Drive the Browser
• Debug the Server
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
• Classpath Control
• Drive the Browser
• Debug the Server
• Container agnostic
Arquillian
• Real Tests (no mocks)
• IDE Friendly
• Test Enrichment
• Classpath Control
• Drive the Browser
• Debug the Server
• Container agnostic
• Extensible platform
Arquillian
public class Greeter {
public void greet(PrintStream to, String name) {
to.println(createGreeting(name));
}
public String createGreeting(String name) {
return "Hello, " + name + "!";
}
}
Arquillian
public class Greeter {
public void greet(PrintStream to, String name) {
to.println(createGreeting(name));
}
public String createGreeting(String name) {
return "Hello, " + name + "!";
}
}
@RunWith(Arquillian.class)
public class GreeterTest {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(Greeter.class)
.addAsManifestResource(EmptyAsset.INSTANCE,
"beans.xml");
}
@Inject
Greeter greeter;
@Test
public void should_create_greeting() {
Assert.assertEquals("Hello, Earthling!",
greeter.createGreeting("Earthling"));
}
}
Functional testing
Test customer requirements
Functional
Integration
Unit
SoapUI
SoapUI is a web service testing application
SoapUI
• Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS
SoapUI is a web service testing application
SoapUI
• Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS
• Allows security and load testing
SoapUI is a web service testing application
SoapUI
• Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS
• Allows security and load testing
• Service mocking
SoapUI is a web service testing application
SoapUI
• Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS
• Allows security and load testing
• Service mocking
• Logging of the test results
SoapUI is a web service testing application
SoapUI
• Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS
• Allows security and load testing
• Service mocking
• Logging of the test results
• Groovy API
SoapUI is a web service testing application
SoapUI
public void testTestCaseRunner() throws Exception {
WsdlProject project = new WsdlProject( "src/dist/sample-soapui-project.xml" );
TestSuite testSuite = project.getTestSuiteByName( "Test Suite" );
TestCase testCase = testSuite.getTestCaseByName( "Test Conversions" );
// create empty properties and run synchronously
TestRunner runner = testCase.run( new PropertiesMap(), false );
assertEquals( Status.FINISHED, runner.getStatus() );
}
Selenium
Selenium is a portable software GUI testing framework for web applications
Selenium
• Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby.
Selenium is a portable software GUI testing framework for web applications
Selenium
• Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby.
• The tests can then be run against most modern web browsers
Selenium is a portable software GUI testing framework for web applications
Selenium
• Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby.
• The tests can then be run against most modern web browsers
• Selenium deploys on Windows, Linux, and Macintosh platforms
Selenium is a portable software GUI testing framework for web applications
Selenium
• Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby.
• The tests can then be run against most modern web browsers
• Selenium deploys on Windows, Linux, and Macintosh platforms
• Selenium provides a record/playback tool for authoring tests without learning a test
scripting language (Selenium IDE)
Selenium is a portable software GUI testing framework for web applications
Selenium
public class Selenium2Example {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
};
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
Summary
Functional
Integration
Unit
5%
15%
80%
TestNG
Hamcrest
Questions?

More Related Content

PPTX
Quickly Testing Qt Desktop Applications
PPTX
Junit 5 - Maior e melhor
ODP
Code Samples
PDF
Gradle For Beginners (Serbian Developer Conference 2013 english)
PDF
OrientDB - The 2nd generation of (multi-model) NoSQL
PPTX
Automation patterns on practice
PDF
PDF
Arquillian in a nutshell
Quickly Testing Qt Desktop Applications
Junit 5 - Maior e melhor
Code Samples
Gradle For Beginners (Serbian Developer Conference 2013 english)
OrientDB - The 2nd generation of (multi-model) NoSQL
Automation patterns on practice
Arquillian in a nutshell

What's hot (19)

PPTX
Android Unit Test
PDF
Java Quiz Questions
PPTX
Appium TestNG Framework and Multi-Device Automation Execution
PPTX
Understanding JavaScript Testing
PDF
Testing with PostgreSQL
PPTX
Getting started with Java 9 modules
PDF
Java8 tgtbatu javaone
PDF
Java Quiz - Meetup
PDF
Gradle talk, Javarsovia 2010
PDF
Implementing quality in Java projects
PDF
Why Kotlin - Apalon Kotlin Sprint Part 1
PPTX
Qunit Java script Un
PPTX
Code generation for alternative languages
DOCX
Junit With Eclipse
PDF
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
PDF
OSGi and Eclipse RCP
PDF
Just Do It! ColdBox Integration Testing
ODP
Unit testing with Qt test
PPTX
Scaladays 2014 introduction to scalatest selenium dsl
Android Unit Test
Java Quiz Questions
Appium TestNG Framework and Multi-Device Automation Execution
Understanding JavaScript Testing
Testing with PostgreSQL
Getting started with Java 9 modules
Java8 tgtbatu javaone
Java Quiz - Meetup
Gradle talk, Javarsovia 2010
Implementing quality in Java projects
Why Kotlin - Apalon Kotlin Sprint Part 1
Qunit Java script Un
Code generation for alternative languages
Junit With Eclipse
Tomasz Polanski - Automated mobile testing 2016 - Testing: why, when, how
OSGi and Eclipse RCP
Just Do It! ColdBox Integration Testing
Unit testing with Qt test
Scaladays 2014 introduction to scalatest selenium dsl
Ad

Viewers also liked (14)

PPTX
Writing quick and beautiful automation code
PDF
Android Espresso
PPTX
Writing and using Hamcrest Matchers
PPTX
Design principles in a nutshell
PDF
Microservices: a journey of an eternal improvement
PPTX
Load-testing 101 for Startups with Artillery.io
PPTX
Search and analyze your data with elasticsearch
PPTX
Going Serverless with CQRS on AWS
PPTX
Choosing Hippo CMS
PDF
Developing functional domain models with event sourcing (sbtb, sbtb2015)
PDF
Microservice Architecture with CQRS and Event Sourcing
PDF
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
PDF
Developing microservices with aggregates (SpringOne platform, #s1p)
PDF
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Writing quick and beautiful automation code
Android Espresso
Writing and using Hamcrest Matchers
Design principles in a nutshell
Microservices: a journey of an eternal improvement
Load-testing 101 for Startups with Artillery.io
Search and analyze your data with elasticsearch
Going Serverless with CQRS on AWS
Choosing Hippo CMS
Developing functional domain models with event sourcing (sbtb, sbtb2015)
Microservice Architecture with CQRS and Event Sourcing
Building and deploying microservices with event sourcing, CQRS and Docker (QC...
Developing microservices with aggregates (SpringOne platform, #s1p)
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Ad

Similar to Testing basics for developers (20)

PDF
JUnit5 and TestContainers
ODP
Good Practices On Test Automation
PPTX
Junit_.pptx
PDF
Web UI test automation instruments
PDF
Guide to the jungle of testing frameworks
PDF
PDF
Guide to the jungle of testing frameworks
PDF
Test Driven Development with JavaFX
PPTX
Renaissance of JUnit - Introduction to JUnit 5
PDF
Testing in android
PPT
比XML更好用的Java Annotation
PDF
Java 5 and 6 New Features
PDF
Testing the Enterprise layers, with Arquillian
PDF
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
ODP
Bring the fun back to java
PDF
Testing Java Code Effectively
PDF
Advanced Java Testing
PDF
How to Build Your Own Test Automation Framework?
PPT
Testing And Drupal
JUnit5 and TestContainers
Good Practices On Test Automation
Junit_.pptx
Web UI test automation instruments
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworks
Test Driven Development with JavaFX
Renaissance of JUnit - Introduction to JUnit 5
Testing in android
比XML更好用的Java Annotation
Java 5 and 6 New Features
Testing the Enterprise layers, with Arquillian
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
Bring the fun back to java
Testing Java Code Effectively
Advanced Java Testing
How to Build Your Own Test Automation Framework?
Testing And Drupal

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PDF
top salesforce developer skills in 2025.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
medical staffing services at VALiNTRY
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
System and Network Administration Chapter 2
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Odoo POS Development Services by CandidRoot Solutions
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
top salesforce developer skills in 2025.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 2 - PM Management and IT Context
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
medical staffing services at VALiNTRY
Understanding Forklifts - TECH EHS Solution
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administration Chapter 2
2025 Textile ERP Trends: SAP, Odoo & Oracle
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf

Testing basics for developers

  • 1. Testing basics for developers Anton Udovychenko 1 1 / 2 0 1 3
  • 2. Agenda • Motivation • Unit testing • JUnit, Mockito, Hamcrest, JsTestDriver • Integration testing • Persistence testing, Arquillian • Functional testing • SoapUI, Selenium • Q&A
  • 5. Unit testing Test small portions of production code Confidence to change Quick Feedback Documentation Functional Integration Unit
  • 7. JUnit lifecycle 1. @BeforeClass 2. For each @Test a) Instanciate test class b) @Before c) Invoke the test d) @After 3. @AfterClass
  • 8. JUnit advanced 1. @Rule and @ClassRule 2. Parametrized 3. Mocks 4. Hamcrest
  • 9. JUnit @Rule public class MyRule implements TestRule { @Override public Statement apply( Statement base, Description description ) { return new MyStatement( base ); } }
  • 10. JUnit @Rule public class MyStatement extends Statement { private final Statement base; public MyStatement( Statement base ) { this.base = base; } @Override public void evaluate() throws Throwable { System.out.println( "before" ); try { base.evaluate(); } finally { System.out.println( "after" ); } } } public class MyRule implements TestRule { @Override public Statement apply( Statement base, Description description ) { return new MyStatement( base ); } }
  • 11. JUnit @Rule public class MyTest { @Rule public MyRule myRule = new MyRule(); @Test public void testRun() { System.out.println( "during" ); } } public class MyRule implements TestRule { @Override public Statement apply( Statement base, Description description ) { return new MyStatement( base ); } } public class MyStatement extends Statement { private final Statement base; public MyStatement( Statement base ) { this.base = base; } @Override public void evaluate() throws Throwable { System.out.println( "before" ); try { base.evaluate(); } finally { System.out.println( "after" ); } } }
  • 12. JUnit @Rule public class MyTest { @Rule public MyRule myRule = new MyRule(); @Test public void testRun() { System.out.println( "during" ); } } public class MyRule implements TestRule { @Override public Statement apply( Statement base, Description description ) { return new MyStatement( base ); } } public class MyStatement extends Statement { private final Statement base; public MyStatement( Statement base ) { this.base = base; } @Override public void evaluate() throws Throwable { System.out.println( "before" ); try { base.evaluate(); } finally { System.out.println( "after" ); } } } Output: before during after
  • 13. JUnit @ClassRule @RunWith(Suite.class) @SuiteClasses({ TestCase1.class, TestCase2.class }) public class AllTests { @ClassRule public static Timeout timeout = new Timeout(3000); }
  • 14. JUnit Parametrized @RunWith(value = Parameterized.class) public class MyTest { private int number; public MyTest(int number) { this.number = number; } @Parameters public static Collection<Object[]> data() { Object[][] data = new Object[][] { { 1 }, { 2 }, { 3 }, { 4 } }; return Arrays.asList(data); } @Test public void pushTest() { System.out.println("Parameterized Number is : " + number); } }
  • 15. Mockito Mockito is a mocking framework for unit tests in Java
  • 16. Mockito import static org.mockito.Mockito.*; import static org.junit.Assert.*; import java.util.Iterator; import org.junit.Test; .... @Test public void iteratorWillReturnHelloWorld(){ //arrange Iterator i=mock(Iterator.class); when(i.next()).thenReturn("Hello").thenReturn("World"); //act String result=i.next()+" "+i.next(); //assert assertEquals("Hello World", result); }
  • 17. Hamcrest Hamcrest is a matchers framework that assists writing software tests
  • 20. Hamcrest assertTrue(foo.contains("someValue") && foo.contains("anotherValue")); assertThat(foo, hasItems("someValue", "anotherValue")); vs assertThat( table, column("Type",contains("A","B","C")).where(cell("Status", is("Ok"))) ); Another example:
  • 21. JsTestDriver JsTestDriver is an open source JavaScript unit tests runner
  • 23. Integration testing Test collaboration between components Database IO system Special environment configuration Functional Integration Unit
  • 24. Persistence testing In memory databases DBUnit
  • 25. Arquillian Arquillian is a platform that simplifies integration testing for Java middleware
  • 27. Arquillian • Real Tests (no mocks) • IDE Friendly
  • 28. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment
  • 29. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment • Classpath Control
  • 30. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment • Classpath Control • Drive the Browser
  • 31. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment • Classpath Control • Drive the Browser • Debug the Server
  • 32. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment • Classpath Control • Drive the Browser • Debug the Server • Container agnostic
  • 33. Arquillian • Real Tests (no mocks) • IDE Friendly • Test Enrichment • Classpath Control • Drive the Browser • Debug the Server • Container agnostic • Extensible platform
  • 34. Arquillian public class Greeter { public void greet(PrintStream to, String name) { to.println(createGreeting(name)); } public String createGreeting(String name) { return "Hello, " + name + "!"; } }
  • 35. Arquillian public class Greeter { public void greet(PrintStream to, String name) { to.println(createGreeting(name)); } public String createGreeting(String name) { return "Hello, " + name + "!"; } } @RunWith(Arquillian.class) public class GreeterTest { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(Greeter.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Inject Greeter greeter; @Test public void should_create_greeting() { Assert.assertEquals("Hello, Earthling!", greeter.createGreeting("Earthling")); } }
  • 36. Functional testing Test customer requirements Functional Integration Unit
  • 37. SoapUI SoapUI is a web service testing application
  • 38. SoapUI • Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS SoapUI is a web service testing application
  • 39. SoapUI • Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS • Allows security and load testing SoapUI is a web service testing application
  • 40. SoapUI • Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS • Allows security and load testing • Service mocking SoapUI is a web service testing application
  • 41. SoapUI • Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS • Allows security and load testing • Service mocking • Logging of the test results SoapUI is a web service testing application
  • 42. SoapUI • Main technologies: SOAP, REST, XML-RPC, HTTP(S), AMF, JDBC, JMS • Allows security and load testing • Service mocking • Logging of the test results • Groovy API SoapUI is a web service testing application
  • 43. SoapUI public void testTestCaseRunner() throws Exception { WsdlProject project = new WsdlProject( "src/dist/sample-soapui-project.xml" ); TestSuite testSuite = project.getTestSuiteByName( "Test Suite" ); TestCase testCase = testSuite.getTestCaseByName( "Test Conversions" ); // create empty properties and run synchronously TestRunner runner = testCase.run( new PropertiesMap(), false ); assertEquals( Status.FINISHED, runner.getStatus() ); }
  • 44. Selenium Selenium is a portable software GUI testing framework for web applications
  • 45. Selenium • Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby. Selenium is a portable software GUI testing framework for web applications
  • 46. Selenium • Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby. • The tests can then be run against most modern web browsers Selenium is a portable software GUI testing framework for web applications
  • 47. Selenium • Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby. • The tests can then be run against most modern web browsers • Selenium deploys on Windows, Linux, and Macintosh platforms Selenium is a portable software GUI testing framework for web applications
  • 48. Selenium • Domain specific language (DSL): Java, C#, Groovy, Perl, PHP, Python and Ruby. • The tests can then be run against most modern web browsers • Selenium deploys on Windows, Linux, and Macintosh platforms • Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE) Selenium is a portable software GUI testing framework for web applications
  • 49. Selenium public class Selenium2Example { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys("Cheese!"); element.submit(); System.out.println("Page title is: " + driver.getTitle()); new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith("cheese!"); } }; System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }