mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Add selenium (#7)
* Fixed formatting * Put cp back * Move agent to stage level * Added agents per stage * Added pipeline level agent declaration * Formatted agents * removed : * need steps in every stage * requires files on jenkins, using sonar without a container. 7/10 chance of working * using sonar container. 4/10 chance of working * specify network for sonar container * Use Ruby image * test container * Added selenium.rb with hello world * first headless test * fix quotes * fix quotes * added Headless dependecy * Fix dependency * Install Firefox driver * Attempt to fix missing firefox package * zzzz * corrected firefox * Added geckkodriver * add firefox * Removed extra quotes * Display page title * Comments and simplifying * Point to Petclinic * uncomment all the build stages * comment out steps * comment out steps * use correct port for tomcat * adding first test * adding dockerfile for selenium testing * Added minitest setup * Fix if * Fixed test invokation * Don’t use Petclinic class * Use instance variables * fix expectation * adding volume mounting * Added minitest * using new selenium docker image in test portion of pipeline * using assert for first test * removing dockerfile * one working test
This commit is contained in:
parent
e5ef12d536
commit
cb8795755a
2 changed files with 81 additions and 21 deletions
65
Jenkinsfile
vendored
65
Jenkinsfile
vendored
|
@ -1,27 +1,50 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent none
|
||||||
docker {
|
|
||||||
image 'maven:3.5.0'
|
|
||||||
args '--network=plumbing_default'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage ('Build') {
|
stage('Build') {
|
||||||
steps {
|
agent {
|
||||||
configFileProvider(
|
docker {
|
||||||
[configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) {
|
image 'maven:3.5.0'
|
||||||
sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true'
|
args '--network=plumbing_default'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
stage ('Deploy to Tomcat') {
|
|
||||||
steps {
|
|
||||||
sh 'cp target/petclinic.war /usr/share/jenkins/ref/petclinic/petclinic.war'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage ('Sonar') {
|
|
||||||
steps {
|
steps {
|
||||||
sh '/var/jenkins_home/sonar/bin/sonar-runner'
|
configFileProvider(
|
||||||
|
[configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) {
|
||||||
|
sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy to Tomcat') {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'alpine'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'cp target/petclinic.war /usr/share/jenkins/ref/petclinic/petclinic.war'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Sonar') {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'sebp/sonar-runner'
|
||||||
|
args '--network=plumbing_default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh '/opt/sonar-runner-2.4/bin/sonar-runner'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Selenium') {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'stein321/selenium-firefox'
|
||||||
|
args '--network=plumbing_default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'ruby petclinic_spec.rb'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
37
petclinic_spec.rb
Normal file
37
petclinic_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
require 'headless'
|
||||||
|
require 'selenium-webdriver'
|
||||||
|
require 'minitest/spec'
|
||||||
|
require 'minitest/autorun'
|
||||||
|
|
||||||
|
describe 'Petlinic' do
|
||||||
|
before do
|
||||||
|
@headless = Headless.new
|
||||||
|
@headless.start
|
||||||
|
|
||||||
|
@driver = Selenium::WebDriver.for :firefox
|
||||||
|
@driver.navigate.to 'http://dashboard:8080/petclinic'
|
||||||
|
@wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
@headless.destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when homepage is available' do
|
||||||
|
it 'I should see Page title' do
|
||||||
|
puts "Title is: #{@driver.title}"
|
||||||
|
assert @driver.title == "PetClinic :: a Spring Framework demonstration"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# describe 'when homepage is available' do
|
||||||
|
# it 'click the find owners button' do
|
||||||
|
# @driver.find_element(:class, "icon-search").click
|
||||||
|
# form = @driver.find_element(:id, "lastName")
|
||||||
|
# puts "form is #{form.label}"
|
||||||
|
# assert @driver.title == "PetClinic :: a Spring Framework demonstration"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue