Friday, September 16, 2016

How to Install Groovy Plugin in the Jenkins and write the groovy code in the console



Install the groovy plugin:

In order to install the groovy plugin in your jenkins server, first we download the the required (groovy) plugin from the plugin repository https://updates.jenkins-ci.org/download/plugins/groovy/.

The plugin extensions are hpi. Once the plugin is downloaded from the plugin repository, go to Manage Jenkins page and Manage Plugins page. Now goto Advanced tab, then chose the plugin file you have downloaded and click upload. This will install the groovy plugin on your jenkins server.

Write groovy code in the groovy script console.

 Refer the https://www.cloudbees.com/jenkins/juc-2015/presentations/JUC-2015-USEast-Groovy-With-Jenkins-McCollum.pdf

groovy Script vs System Groovy Script

The plain "Groovy Script" is run in a forked JVM, on the slave where the build is run. It's the basically the same as running the "groovy" command and pass in the script.

The system groovy script, OTOH, runs inside the Jenkins master's JVM. Thus it will have access to all the internal objects of Jenkins, so you can use this to alter the state of Jenkins

Where to store the script?

● Can put it in source and pull it from source
● Or you can put the script directly into the command box that is provided


Friday, March 25, 2016

Configure Protractor


Follow these steps to configure the protractor.

1. install npm from https://nodejs.org/download/release/npm/
2. install protractor using "npm install -g protractor"
3. install webdriver using webdriver-manager update.
4. start the selenium server using webdriver manager
     webdriver-manager start
5. Now protractor will accept the configuration file (protractor.conf.js).

   exports.config ={
         seleniumAddress: 'http://localhost:4444/wd/hub'
         jasmineNodeOpts:{
                  showColors: true,
                  defaultTimeoutInterval: 3000  

           }
     }

6. protractor can start the selenium server if we provide the path to the selenium server standalone jar. This will slow down the overall time it takes to run the tests due to protractor having to start the server as opposed to an instance already running:
seleniumServer: './node_module/protractor/selenium/selenium-server-standalone-2.42.0.jar'

https://github.com/angular/protractor/blob/master/docs/api.md

Sunday, January 31, 2016

SOAP mocking SOAPUI Groovy XML Parsing


Mocking is one of most regular tasks that testers need to do as part of their Job. Handling the mock using groovy bit challenging. Following is an example to parse the request xml and evaluate the xpath on the request xml.

Example:
import java.text.*
import groovy.lang.*
import java.util.*
import com.eviware.soapui.support.XmlHolder

def sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
def currentOrderId = new Date().getTime()
def holder = new XmlHolder(mockRequest.requestContent)
holder.namespaces['ns1'] = "http://xxxxxx/aaaaa/fffffffffffff/2.0/vvvvvvvv/4.0"
holder.namespaces['ns'] = "http://xxxxxx/aaaaa/ffffffffffffff/2.0/bbbbbbbb/4.0"
def nodeV2 =  holder.getDomNodes("//*")[3]
log.info nodeV2.getNodeName()
def hubId= nodeV2.attributes.getNamedItem("Hub").getNodeValue()

if(hubId.equals(400)){
context.setProperty("request1", hubId)
}


//def nodeV =  holder.getNodeValue("//ns1:OrderID")
//def nodeV =  holder.getDomNode("//ns1:OrderID")
//log.info nodeV.attributes.getNamedItem("id").getNodeValue()

Thursday, July 9, 2015

Sunday, June 14, 2015

References

 <!--https://cdivilly.wordpress.com/2009/07/20/maven-jruby-and-rails-migrations/-->
                            <!--http://www.weblogism.com/item/344/call-rake-from-maven-->
                            <!--http://www.ning.com/code/2011/09/jruby-sinatra-web-service-as-an-executable-jar/-->

 <!--http://chris.chowie.net/2011/08/28/Sinatra-with-JRuby-on-Heroku/-->

Wednesday, May 20, 2015

Sunday, November 30, 2014

Transforming a line item



Extending the World class is one way to extend the functionality of Cucumber. In this section we will
look at another. In a few of our step definitions we have specified that we wanted to use a specific
“line item”. In those steps we had to always take the String Cucumber passed and convert it to a
number using the to_i method. If we want Cucumber to automatically convert it for us we can use
a Transformation. Let’s look at that now.
                                        The first thing we need to do is create a new file in the support directory named transformations.rb. The file name doesn’t matter; I just like to collect all of my transformations in the same file. On a typically large project you might see up to five or six transformations. In this file we will create our first transformation:

  Transform /^line item (\d+)$/ do |line_string|
   line_string.to_i
  end


This structure should look familiar. It is very similar to step definitions except it begins with the
word Transform instead of Given, When, or Then. To break it down completely, what we are saying
with this code is find a capture group of a step definition (portion of a step definition surrounded by
parentheses) that contains “line item” plus a number and perform the following action on the value
of the number. In order for this Transformation to find the appropriate step definitions we will need
to move the opening parentheses to surround the entire match.

Then /^I should see "([^"]*)" as the name for (line item \d+)$/ do |name, lin\
e_item|

Now we no longer need to convert the line_item parameter to a number since the Transformation
takes care of this for us.

       This technique is very useful when you have values that need to be converted and you wish to move
the logic from multiple steps to one Transformation. For example, imagine you need to perform a
lot of date handling. It would be nice to say things like today, tomorrow, or yesterday and have a
Transformation object create a date object.

Source: Cucumber and Cheese book