SlideShare a Scribd company logo
WuKong - Framework for
Integrated Test
Yang Lu
Agenda
• Background
• Why, What, How
• Goals of Framework
• Test Scene
• Run Test
• Demo
• Questions
Background
• WuKong, also known as the Monkey King, is a main character in
the Chinese classical novel Journey to the West.
• WuKong last release was Hestia.
• Wukong, is a Framework for Integrated Test.
Why we do?
• We need to manage Test Case.
• We need to run Test Case.
• We need to write Test Case.
– Web UI Test
– Http Test
– Web Service Test
– RPC Test
– Database Test
– Mobile Test
– ……
Manager
Runner
Test
Case
What we do?
• Test Web App
– Manage Test Case
• Test Runner
– Run Test Case
• Integration Test-Framework
– JunitX
– TestNG
• Test Scenario-Plugin
– Selenium
– WebDriver
– HtmlUnit
– Web Service(CXF)
– RPC
– Rubidium
– DB Unit
How we do? – Integration Test Framework
Plugin Http
Plugin
Framework Junit4
Runner TestNGWuKong API WuKong Impl
Module Manager Report ……
Test Engine Web App Mobile App ……
Test Case TestCase1 TestCase2 ……
Service
Plugin
Web
Plugin
DB Plugin Mobile Plugin
Runner
Test Case
ProgressModule
Test Runner
Junit3 Framework
Junit4 Framework
100%
Database Test Plugin
CXF Test Plugin
RPC Test Plugin
Web UI Test Plugin
Http Test Plugin
Mobile Test Plugin
Business Modules
Web App
How we do? - Maven Projects
100%
100%
100%
100%
100%
100%
100%
0%
25%
25%
Example/Demo 100%
Goals of Framework
 Dependency injection / Spring IOC
 Annotations Oriented Programming(AOP)
 Code-Reuse / Loose Coupling
 Simplify Code
 Good Scalability
 Well defined API
 Apply to Multi-Scenarios
Scene – How to Write Test Case?
 How to define Test Project Structure?
 Spring Test Case
 Config Test Case
 DBase Test Case
 Web Service Test Case
 RPC Service Test Case
 Web UI Test Case(Page Driver)
 Web UI Test Case(Command Driver)
Scene – How to define Test Project Structure?
Test Resource files
(Test Config File)
Junit4 Test Case
Test Service API
Log
Scene – How to Write a Spring Test Case?
API
public interface IHelloService {
/**
* @param name
* @return
*/
public String hello(String name);
}
IMPL
public class HelloServiceImpl implements IHelloService {
@Override
public String hello(String name) {
return name.toUpperCase();
}
}
How to Inject a Spring Bean?
@AnnoSpringContext( locations= {"/applicationContext.xml"} )
public class DemoSpringBaseTestCase extends SpringBaseTestCase {
@AnnoSpringBean(springContextKey="{helloService}")
private IHelloService helloService;
@Test
public void test() {
assertEquals(helloService.hello("summer"), "SUMMER");
}
}
Spring Bean XML
<?xml version="1.0" encoding="UTF-8"?>
<beans ……>
<bean id="helloService"
class="com.dell.hestia.testcase.demo.spring.impl
.HelloServiceImpl">
</bean>
</beans>
4
2
3
1
Spring
Content
Spring
Bean
Spring
Bean
Scene – How to Write a Config Test Case?
Config in XML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<config>
<index>https://www.google.com.hk/</name1>
<email>gmluyang@gmail.com</name3>
<passwd>xxxxxx</name4>
</config>
How to Inject a Config field?
@AnnoConfigContext(paths="wukong-config.xml")
public class WebUIWebDriverPageDriver3Test extends SpringTestCase implements IConfigTestCase {
@AnnoConfigField(key="index")
private String index;
@AnnoConfigField(key="email")
private String email;
@AnnoConfigField(key="passwd")
private String passwd;
@Test
public void testConfig() throws Exception {
assertEquals(index, "https://www.google.com.hk/");
assertEquals(email, "gmluyang@gmail.com");
assertEquals(passwd, "xxxxxx");
}
}
2
1
Tag
Interface
Scene – How to Write a DBase Test Case?
SQL and Service in XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN“ "sql-map-2.dtd">
<sqlMap namespace="UserService">
<typeAlias alias="User" type="com.dell.wukong.testcase.demo.domain.User" />
<select id="queryUsers" resultClass="User">
SELECT u.* FROM user u
</select>
</sqlMap>
How to Inject a DAO Service Bean?
@AnnoSpringContext(locations={"classpath:spring-testcase-demo-dao-service.xml"})
@AnnoDataSource( database = DataBase.MySQL, pool = ConnPool.DBCP )
public class DBaseTestCase extends SpringTestCase implements IDBaseTestCase {
@AnnoSpringBean()
private IUserService userService;
@Test
public void test1() {
assertEquals(userService.queryUsers().size(), 0);
}
}
2
1
Data Source
Anno
Database
type
Conn Pool
Tag
Interface
Spring
Bean
Spring
Bean
Spring
Content
Scene – How to Write a CXF Test Case?
How to create a CXF-Web Service Bean?
public class CXFTestCase extends SpringTestCase implements ICXFTestCase {
@AnnoServiceCXF()
private IHelloService helloService;
@Test
public void test1() {
assertEquals(helloService.hello("summer"), "SUMMER");
}
}
Tag
Interface
CXF Service
Anno
Web Service CXF Client API in XML
<?xml version="1.0" encoding="UTF-8"?>
<beans …>
<bean id="helloService"
class="com.dell.wukong.testcase.demo.service.impl.HelloServiceImpl"></bean>
<jaxws:server id="helloService"
serviceBean="#helloService" address="http://localhost:8080/wukong/ws/helloWebService">
</jaxws:server>
</beans>
CXF Service
Bean
Scene – How to Write a RPC Test Case?
RPC Client API in XML
<?xml version="1.0" encoding="UTF-8"?>
<beans …>
<dubbo:reference id="helloService"
interface="com.dell.wukong.testcase.demo.service.api.IHelloService"
url="dubbo://127.0.0.1:20880/com.dell.wukong.testcase.demo.service.api.IHelloService"/>
</beans>
How to Inject a RPC Service Bean?
public class RPCTestCase extends SpringTestCase implements IRPCTestCase {
@AnnoServiceRPC()
private IHelloService helloService;
@Test
public void test1() {
assertEquals(helloService.hello("summer"), "SUMMER");
}
}
2
1
Tag
Interface
RPC Service
Anno
RPC Service
Bean
TestCase base on WebDriverTestCase base on HttpUnit
Scene – Write a Web UI Test Case By Page Driver
public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements
IWebUIHttpUnitTestCase {
public static String index = "https://www.google.com.hk/";
@AnnoBrowser(browser=Browser.FIREFOX)
private IBrowser browser;
@Test
public void testLogin() throws Exception {
// indexPage
IPage indexPage = this.browser.getPage(index);
// loginPage
IPage loginPage = indexPage.onClick("gbi4s1");
loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com");
loginPage.setHtmlInputValue(“Passwd”, "*");
// loginedPage
IPage loginedPage = loginPage.onClick("signIn");
// assertEquals
assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu"));
}
}
public class WebUIHtmlUnitPageDriverTest extends SpringTestCase
implements IWebUIWebDriverTestCase {
public static String index = "https://www.google.com.hk/";
@ AnnoBrowser(browser=Browser.FIREFOX)
private IBrowser browser;
@Test
public void testLogin() throws Exception {
// indexPage
IPage indexPage = this.browser.getPage(index);
// loginPage
IPage loginPage = indexPage.onClick("gbi4s1");
loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com");
loginPage.setHtmlInputValue("Passwd", "*");
// loginedPage
IPage loginedPage = loginPage.onClick("signIn");
// assertEquals
assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu"));
}
}
AnnoBrowser AnnoBrowser
Program to an interface and Annotation, not an implementation
1
2
3
1
2
3
Command DriverPage Driver
Scene – How to Write a Web UI Test Case by
Command Driver?
public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements
IWebUIHttpUnitTestCase {
public static String index = "https://www.google.com.hk/";
@AnnoBrowser(browser=Browser.FIREFOX)
private IBrowser browser;
@Test
public void testLogin() throws Exception {
// indexPage
IPage indexPage = this.browser.getPage(index);
}
}
public class WebUIHtmlUnitPageDriverTest extends SpringTestCase
implements IWebUIHttpUnitTestCase {
public static String index = "https://www.google.com.hk/";
@AnnoBrowser(browser=Browser.FIREFOX)
private IBrowser browser;
@Test
public void testLogin() throws Exception {
// indexPage
IPage indexPage = this.browser.getPage(index);
}
}
// loginedPage
IPage loginedPage = indexPage.execute( new LoginCommand() );
Command is a set of program logic
can be reused
// loginPage
IPage loginPage = indexPage.onClick("gbi4s1");
loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com");
loginPage.setHtmlInputValue(“Passwd”, "*");
// loginedPage
IPage loginedPage = loginPage.onClick("signIn");
// assertEquals
assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu"));
How to Run Test Case?
 Eclipse IDE
 Maven
 WuKong Runner
 How to manage and use different release
JAR of test project running at the same time?
How to Run Test Case? – Eclipse IDE
Local Debug
How to Run Test Case? – Maven
Integration Test
How to Run Test Case? – WuKong Runner
Test
Classes
Test XML
File
Test XML
Element
Test XML
Text
Runner
API
Run Test
Programmatically
using Java
How to Run Test Case? - How to manage
and use different release JAR of one project
running at the same time?
TestRunner
TestCaseClassLoader is custom Class Loader, use to isolate Class
TestCaseClassLoader - 1
Test-demo-1.0.0.jar
TestRunner
TestCaseClassLoader - 2
Test-demo-2.0.0.jar
Demo - Web App : Login
Demo – Web App : How to Manage Test
Case
Demo – Web App : How to watch Test
Web-App JVM
Questions
Thank you

More Related Content

PDF
Developing Modern Java Web Applications with Java EE 7 and AngularJS
PDF
Ember testing internals with ember cli
PPTX
BDD / cucumber /Capybara
PPTX
Test like a pro with Ember.js
PDF
KISS Automation.py
PDF
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
PDF
Web ui tests examples with selenide, nselene, selene & capybara
PPT
Testing Any Site With Cucumber and Selenium
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Ember testing internals with ember cli
BDD / cucumber /Capybara
Test like a pro with Ember.js
KISS Automation.py
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
Web ui tests examples with selenide, nselene, selene & capybara
Testing Any Site With Cucumber and Selenium

What's hot (20)

PDF
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
PDF
Search and play more than 50 clips
PDF
Modular Test-driven SPAs with Spring and AngularJS
PDF
High Performance JavaScript - jQuery Conference SF Bay Area 2010
PDF
BDD in Java using Cucumber
PDF
Introduction to Retrofit
PPTX
Enough with the JavaScript already!
PDF
Using Selenium to Improve a Teams Development Cycle
KEY
Cross-platform logging and analytics
PPTX
Web automation in BDD
PDF
Behavior Driven Development and Automation Testing Using Cucumber
PPT
A journey beyond the page object pattern
PDF
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015
PPT
Java 6 [Mustang] - Features and Enchantments
PDF
APIs: A Better Alternative to Page Objects
PDF
API Design & Security in django
PDF
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
PDF
jQuery Proven Performance Tips & Tricks
PDF
Reactive Thinking in Java with RxJava2
PDF
You do not need automation engineer - Sqa Days - 2015 - EN
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Search and play more than 50 clips
Modular Test-driven SPAs with Spring and AngularJS
High Performance JavaScript - jQuery Conference SF Bay Area 2010
BDD in Java using Cucumber
Introduction to Retrofit
Enough with the JavaScript already!
Using Selenium to Improve a Teams Development Cycle
Cross-platform logging and analytics
Web automation in BDD
Behavior Driven Development and Automation Testing Using Cucumber
A journey beyond the page object pattern
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015
Java 6 [Mustang] - Features and Enchantments
APIs: A Better Alternative to Page Objects
API Design & Security in django
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
jQuery Proven Performance Tips & Tricks
Reactive Thinking in Java with RxJava2
You do not need automation engineer - Sqa Days - 2015 - EN
Ad

Similar to WuKong - Framework for Integrated Test (20)

PDF
Revolution or Evolution in Page Object
PPT
比XML更好用的Java Annotation
PPTX
Das kannste schon so machen
KEY
Week 4 - jQuery + Ajax
PDF
UI-Testing - Selenium? Rich-Clients? Containers? @APEX connect 2018
PDF
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
PDF
Future of Web Apps: Google Gears
PPTX
Javascript first-class citizenery
PDF
Google guava
PDF
Apache Wicket Web Framework
PDF
vJUG - The JavaFX Ecosystem
PPTX
Test automation
PDF
Web UI test automation instruments
PPTX
Тарас Олексин - Sculpt! Your! Tests!
KEY
Integrating Wicket with Java EE 6
PPTX
jQuery for web development
PPT
Play framework
PDF
Developing, Testing and Scaling with Apache Camel - UberConf 2015
PDF
Workshop 23: ReactJS, React & Redux testing
PPTX
Introduction to Spring Boot
Revolution or Evolution in Page Object
比XML更好用的Java Annotation
Das kannste schon so machen
Week 4 - jQuery + Ajax
UI-Testing - Selenium? Rich-Clients? Containers? @APEX connect 2018
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Future of Web Apps: Google Gears
Javascript first-class citizenery
Google guava
Apache Wicket Web Framework
vJUG - The JavaFX Ecosystem
Test automation
Web UI test automation instruments
Тарас Олексин - Sculpt! Your! Tests!
Integrating Wicket with Java EE 6
jQuery for web development
Play framework
Developing, Testing and Scaling with Apache Camel - UberConf 2015
Workshop 23: ReactJS, React & Redux testing
Introduction to Spring Boot
Ad

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
A Presentation on Artificial Intelligence
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Modernizing your data center with Dell and AMD
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
A Presentation on Artificial Intelligence
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Modernizing your data center with Dell and AMD
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Weekly Chronicles - August'25 Week I

WuKong - Framework for Integrated Test

  • 1. WuKong - Framework for Integrated Test Yang Lu
  • 2. Agenda • Background • Why, What, How • Goals of Framework • Test Scene • Run Test • Demo • Questions
  • 3. Background • WuKong, also known as the Monkey King, is a main character in the Chinese classical novel Journey to the West. • WuKong last release was Hestia. • Wukong, is a Framework for Integrated Test.
  • 4. Why we do? • We need to manage Test Case. • We need to run Test Case. • We need to write Test Case. – Web UI Test – Http Test – Web Service Test – RPC Test – Database Test – Mobile Test – …… Manager Runner Test Case
  • 5. What we do? • Test Web App – Manage Test Case • Test Runner – Run Test Case • Integration Test-Framework – JunitX – TestNG • Test Scenario-Plugin – Selenium – WebDriver – HtmlUnit – Web Service(CXF) – RPC – Rubidium – DB Unit
  • 6. How we do? – Integration Test Framework Plugin Http Plugin Framework Junit4 Runner TestNGWuKong API WuKong Impl Module Manager Report …… Test Engine Web App Mobile App …… Test Case TestCase1 TestCase2 …… Service Plugin Web Plugin DB Plugin Mobile Plugin Runner Test Case
  • 7. ProgressModule Test Runner Junit3 Framework Junit4 Framework 100% Database Test Plugin CXF Test Plugin RPC Test Plugin Web UI Test Plugin Http Test Plugin Mobile Test Plugin Business Modules Web App How we do? - Maven Projects 100% 100% 100% 100% 100% 100% 100% 0% 25% 25% Example/Demo 100%
  • 8. Goals of Framework  Dependency injection / Spring IOC  Annotations Oriented Programming(AOP)  Code-Reuse / Loose Coupling  Simplify Code  Good Scalability  Well defined API  Apply to Multi-Scenarios
  • 9. Scene – How to Write Test Case?  How to define Test Project Structure?  Spring Test Case  Config Test Case  DBase Test Case  Web Service Test Case  RPC Service Test Case  Web UI Test Case(Page Driver)  Web UI Test Case(Command Driver)
  • 10. Scene – How to define Test Project Structure? Test Resource files (Test Config File) Junit4 Test Case Test Service API Log
  • 11. Scene – How to Write a Spring Test Case? API public interface IHelloService { /** * @param name * @return */ public String hello(String name); } IMPL public class HelloServiceImpl implements IHelloService { @Override public String hello(String name) { return name.toUpperCase(); } } How to Inject a Spring Bean? @AnnoSpringContext( locations= {"/applicationContext.xml"} ) public class DemoSpringBaseTestCase extends SpringBaseTestCase { @AnnoSpringBean(springContextKey="{helloService}") private IHelloService helloService; @Test public void test() { assertEquals(helloService.hello("summer"), "SUMMER"); } } Spring Bean XML <?xml version="1.0" encoding="UTF-8"?> <beans ……> <bean id="helloService" class="com.dell.hestia.testcase.demo.spring.impl .HelloServiceImpl"> </bean> </beans> 4 2 3 1 Spring Content Spring Bean Spring Bean
  • 12. Scene – How to Write a Config Test Case? Config in XML <?xml version="1.0" encoding="ISO-8859-1" ?> <config> <index>https://www.google.com.hk/</name1> <email>gmluyang@gmail.com</name3> <passwd>xxxxxx</name4> </config> How to Inject a Config field? @AnnoConfigContext(paths="wukong-config.xml") public class WebUIWebDriverPageDriver3Test extends SpringTestCase implements IConfigTestCase { @AnnoConfigField(key="index") private String index; @AnnoConfigField(key="email") private String email; @AnnoConfigField(key="passwd") private String passwd; @Test public void testConfig() throws Exception { assertEquals(index, "https://www.google.com.hk/"); assertEquals(email, "gmluyang@gmail.com"); assertEquals(passwd, "xxxxxx"); } } 2 1 Tag Interface
  • 13. Scene – How to Write a DBase Test Case? SQL and Service in XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN“ "sql-map-2.dtd"> <sqlMap namespace="UserService"> <typeAlias alias="User" type="com.dell.wukong.testcase.demo.domain.User" /> <select id="queryUsers" resultClass="User"> SELECT u.* FROM user u </select> </sqlMap> How to Inject a DAO Service Bean? @AnnoSpringContext(locations={"classpath:spring-testcase-demo-dao-service.xml"}) @AnnoDataSource( database = DataBase.MySQL, pool = ConnPool.DBCP ) public class DBaseTestCase extends SpringTestCase implements IDBaseTestCase { @AnnoSpringBean() private IUserService userService; @Test public void test1() { assertEquals(userService.queryUsers().size(), 0); } } 2 1 Data Source Anno Database type Conn Pool Tag Interface Spring Bean Spring Bean Spring Content
  • 14. Scene – How to Write a CXF Test Case? How to create a CXF-Web Service Bean? public class CXFTestCase extends SpringTestCase implements ICXFTestCase { @AnnoServiceCXF() private IHelloService helloService; @Test public void test1() { assertEquals(helloService.hello("summer"), "SUMMER"); } } Tag Interface CXF Service Anno Web Service CXF Client API in XML <?xml version="1.0" encoding="UTF-8"?> <beans …> <bean id="helloService" class="com.dell.wukong.testcase.demo.service.impl.HelloServiceImpl"></bean> <jaxws:server id="helloService" serviceBean="#helloService" address="http://localhost:8080/wukong/ws/helloWebService"> </jaxws:server> </beans> CXF Service Bean
  • 15. Scene – How to Write a RPC Test Case? RPC Client API in XML <?xml version="1.0" encoding="UTF-8"?> <beans …> <dubbo:reference id="helloService" interface="com.dell.wukong.testcase.demo.service.api.IHelloService" url="dubbo://127.0.0.1:20880/com.dell.wukong.testcase.demo.service.api.IHelloService"/> </beans> How to Inject a RPC Service Bean? public class RPCTestCase extends SpringTestCase implements IRPCTestCase { @AnnoServiceRPC() private IHelloService helloService; @Test public void test1() { assertEquals(helloService.hello("summer"), "SUMMER"); } } 2 1 Tag Interface RPC Service Anno RPC Service Bean
  • 16. TestCase base on WebDriverTestCase base on HttpUnit Scene – Write a Web UI Test Case By Page Driver public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements IWebUIHttpUnitTestCase { public static String index = "https://www.google.com.hk/"; @AnnoBrowser(browser=Browser.FIREFOX) private IBrowser browser; @Test public void testLogin() throws Exception { // indexPage IPage indexPage = this.browser.getPage(index); // loginPage IPage loginPage = indexPage.onClick("gbi4s1"); loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com"); loginPage.setHtmlInputValue(“Passwd”, "*"); // loginedPage IPage loginedPage = loginPage.onClick("signIn"); // assertEquals assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu")); } } public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements IWebUIWebDriverTestCase { public static String index = "https://www.google.com.hk/"; @ AnnoBrowser(browser=Browser.FIREFOX) private IBrowser browser; @Test public void testLogin() throws Exception { // indexPage IPage indexPage = this.browser.getPage(index); // loginPage IPage loginPage = indexPage.onClick("gbi4s1"); loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com"); loginPage.setHtmlInputValue("Passwd", "*"); // loginedPage IPage loginedPage = loginPage.onClick("signIn"); // assertEquals assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu")); } } AnnoBrowser AnnoBrowser Program to an interface and Annotation, not an implementation 1 2 3 1 2 3
  • 17. Command DriverPage Driver Scene – How to Write a Web UI Test Case by Command Driver? public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements IWebUIHttpUnitTestCase { public static String index = "https://www.google.com.hk/"; @AnnoBrowser(browser=Browser.FIREFOX) private IBrowser browser; @Test public void testLogin() throws Exception { // indexPage IPage indexPage = this.browser.getPage(index); } } public class WebUIHtmlUnitPageDriverTest extends SpringTestCase implements IWebUIHttpUnitTestCase { public static String index = "https://www.google.com.hk/"; @AnnoBrowser(browser=Browser.FIREFOX) private IBrowser browser; @Test public void testLogin() throws Exception { // indexPage IPage indexPage = this.browser.getPage(index); } } // loginedPage IPage loginedPage = indexPage.execute( new LoginCommand() ); Command is a set of program logic can be reused // loginPage IPage loginPage = indexPage.onClick("gbi4s1"); loginPage.setHtmlInputValue("Email", "gmluyang@gmail.com"); loginPage.setHtmlInputValue(“Passwd”, "*"); // loginedPage IPage loginedPage = loginPage.onClick("signIn"); // assertEquals assertEquals(true, loginedPage.isElementTextContent("gbi4t", "Yang Lu"));
  • 18. How to Run Test Case?  Eclipse IDE  Maven  WuKong Runner  How to manage and use different release JAR of test project running at the same time?
  • 19. How to Run Test Case? – Eclipse IDE Local Debug
  • 20. How to Run Test Case? – Maven Integration Test
  • 21. How to Run Test Case? – WuKong Runner Test Classes Test XML File Test XML Element Test XML Text Runner API Run Test Programmatically using Java
  • 22. How to Run Test Case? - How to manage and use different release JAR of one project running at the same time? TestRunner TestCaseClassLoader is custom Class Loader, use to isolate Class TestCaseClassLoader - 1 Test-demo-1.0.0.jar TestRunner TestCaseClassLoader - 2 Test-demo-2.0.0.jar
  • 23. Demo - Web App : Login
  • 24. Demo – Web App : How to Manage Test Case
  • 25. Demo – Web App : How to watch Test Web-App JVM