Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
#JCConf
Java
Gradle Docker


JCConf Taiwan 2015 Workshop
Outline
• Introduction
• Docker Image Installation
• Classical Geb Testing
• Geb Test with Dockerize Browser
• Gradle Buil...
#JCConf
Hackpad
https://goo.gl/PbW62V
#JCConf
Introduction
Package

Library
Application
Server
e2e

test
auto test success
local
debug
test case success success
remote
debug
test failed
test failed test failed
#JCConf
Docker Image Installation
docker load
• docker load --input ${ }/jcconf_main.tar
• docker load --input ${ }/jcconf_client.tar
•
• docker images
• tr...
#JCConf
Let’s Start!
#JCConf
Classical Geb Testing
Browser
with
WebDriver
control
test results
Java
Gradle
Geb
•
•
#JCConf
Demo Repository
GebConfig
1. firefox {
2. driver = {
3. DesiredCapabilities capabilities = DesiredCapabilities.firefox()
4. def host = Sys...
Target
•
•
• Google Chrome
• Firefox
#JCConf
#JCConf
Geb Web Testing
without Docker
#JCConf
Run Gradle
./gradlew firefoxTest
./gradlew chromeTest
Get Source Code
https://github.com/TrunkWorkshop/jcconf-2015-java-do...
Testing with Jenkins CI
• daily build
• code committed
• pull request
• before staging
• before release
• trigger manually
Jenkins CI with Real Browser ?
• PhantomJS(headless) is not real
?
?
HOW-TO
#JCConf
Geb Test
with
Dockerize Browser
browser
test case
control
result
VNC
#JCConf
docker browser
docker-compose up client
#JCConf
View Docker Inside
vnc://DOCKER_HOST:5999
password: secret
• Jenkins CI Test Failed
• CI
•
•
#JCConf
export JCCONF_CLIENT_PORT_4444_TCP_ADDR=DOCKER_HOST
export JCCONF_CLIENT_PORT_4444_TCP_PORT=4444
GebConfig
1. firefox {
2. driver = {
3. DesiredCapabilities capabilities = DesiredCapabilities.firefox()
4. def host = Sys...
#JCConf
local test + docker browser
gradle remoteFirefoxTest
#JCConf
vnc://DOCKER_HOST:5999
password: secret
#JCConf
Gradle Build and Geb Test
with
Docker
client
env
project
env
browser test case
control
result
VNC JAVA
gradle
• CI
•
•
• migrate
#JCConf
docker-compose up main
#JCConf
vnc://dockerhost:5999
password: secret
#JCConf
docker-compose
main:
container_name: jcconf_main
image: trunk/groovy_gradle
command: "/bin/bash -l -c 'gradle firefoxTest'"
links:
- clie...
Jenkins with Docker
docker-compose up main
Upcoming SlideShare
Loading in …5
×

JCConf 2015 workshop 動手玩 Java 專案建置工具

介紹如何透過 Docker 以及 Gradle 進行前端 e2e testing

JCConf 2015 workshop 動手玩 Java 專案建置工具

  1. 1. #JCConf Java Gradle Docker 
 JCConf Taiwan 2015 Workshop
  2. 2. Outline • Introduction • Docker Image Installation • Classical Geb Testing • Geb Test with Dockerize Browser • Gradle Build and Geb Test with Docker
  3. 3. #JCConf Hackpad https://goo.gl/PbW62V
  4. 4. #JCConf Introduction
  5. 5. Package
 Library Application Server e2e
 test
  6. 6. auto test success local debug test case success success remote debug test failed test failed test failed
  7. 7. #JCConf Docker Image Installation
  8. 8. docker load • docker load --input ${ }/jcconf_main.tar • docker load --input ${ }/jcconf_client.tar • • docker images • trunk/groovy_gradle • vvoyer/docker-selenium-firefox-chrome
  9. 9. #JCConf Let’s Start!
  10. 10. #JCConf Classical Geb Testing
  11. 11. Browser with WebDriver control test results Java Gradle Geb
  12. 12. • •
  13. 13. #JCConf Demo Repository
  14. 14. GebConfig 1. firefox { 2. driver = { 3. DesiredCapabilities capabilities = DesiredCapabilities.firefox() 4. def host = System.env.JCCONF_CLIENT_PORT_4444_TCP_ADDR ?: 'localhost' 5. def port = System.env.JCCONF_CLIENT_PORT_4444_TCP_PORT ?: '4444' 6. 7. if (host == 'localhost') { 8. new FirefoxDriver() 9. } 10. else { 11. URL url = new URL("http://$host:$port/wd/hub") 12. new RemoteWebDriver(url, capabilities) 13. } 14. } 15.} 16. src/test/resources/GebConfig.groovy
  15. 15. Target • • • Google Chrome • Firefox
  16. 16. #JCConf
  17. 17. #JCConf Geb Web Testing without Docker
  18. 18. #JCConf
  19. 19. Run Gradle ./gradlew firefoxTest ./gradlew chromeTest Get Source Code https://github.com/TrunkWorkshop/jcconf-2015-java-docker git clone https://github.com/TrunkWorkshop/jcconf-2015-java-docker.git
  20. 20. Testing with Jenkins CI • daily build • code committed • pull request • before staging • before release • trigger manually
  21. 21. Jenkins CI with Real Browser ? • PhantomJS(headless) is not real ? ? HOW-TO
  22. 22. #JCConf Geb Test with Dockerize Browser
  23. 23. browser test case control result VNC
  24. 24. #JCConf docker browser docker-compose up client
  25. 25. #JCConf View Docker Inside vnc://DOCKER_HOST:5999 password: secret
  26. 26. • Jenkins CI Test Failed • CI • •
  27. 27. #JCConf export JCCONF_CLIENT_PORT_4444_TCP_ADDR=DOCKER_HOST export JCCONF_CLIENT_PORT_4444_TCP_PORT=4444
  28. 28. GebConfig 1. firefox { 2. driver = { 3. DesiredCapabilities capabilities = DesiredCapabilities.firefox() 4. def host = System.env.JCCONF_CLIENT_PORT_4444_TCP_ADDR ?: 'localhost' 5. def port = System.env.JCCONF_CLIENT_PORT_4444_TCP_PORT ?: '4444' 6. 7. if (host == 'localhost') { 8. new FirefoxDriver() 9. } 10. else { 11. URL url = new URL("http://$host:$port/wd/hub") 12. new RemoteWebDriver(url, capabilities) 13. } 14. } 15.} 16. src/test/resources/GebConfig.groovy
  29. 29. #JCConf local test + docker browser gradle remoteFirefoxTest
  30. 30. #JCConf vnc://DOCKER_HOST:5999 password: secret
  31. 31. #JCConf Gradle Build and Geb Test with Docker
  32. 32. client env project env browser test case control result VNC JAVA gradle
  33. 33. • CI • • • migrate
  34. 34. #JCConf docker-compose up main
  35. 35. #JCConf vnc://dockerhost:5999 password: secret
  36. 36. #JCConf docker-compose
  37. 37. main: container_name: jcconf_main image: trunk/groovy_gradle command: "/bin/bash -l -c 'gradle firefoxTest'" links: - client volumes: - ./:/jcconf_main working_dir: /jcconf_main client: container_name: jcconf_client image: vvoyer/docker-selenium-firefox-chrome ports: - "4444:4444" - "5999:5999"
  38. 38. Jenkins with Docker docker-compose up main

×