Saturday, February 7, 2015

Run soapUI project using ANT script



Following is the sample ANT script to run soapUI project. To run it, you need to copy all the jar files from soapUI installation folder and also add soapUI-xxx.jar from bin folder, and put them in the lib folder and add it to ant classpath.

This ant script support:
1. you can run test by specifying the paramters like suite name, url, user name, password etc.
2. by default it will run all the test cases in the project.
3. it will generate JUnit compatible report.

Please refer my github reporitory for the whole sample code.

<project name="WS-Test"  default="test" >
<property file="build.properties"/>
<property name="test.dir" value="test-results"/>
<property name="project.dir" location="project"/>

<target name="clean">
       <delete dir="${test.dir}"/>
    </target>

<target name="init">
      <mkdir dir="${test.dir}"/>
    </target>

<target name="test-with-properties" depends="init">
<java classname="com.eviware.soapui.tools.SoapUITestCaseRunner" errorproperty="tests-failed" fork="yes" dir="${test.dir}">
 <arg line="-j -M -r -a -f${basedir}/${test.dir}"/>
 <arg value="-e${wsdl.url}"/>
 <arg value="-s${soapui.testsuite}"/>
 <arg value="${project.dir}/${soapui.project}"/>
 <arg value="-x${user.name}"/>
 <arg value="-x${user.password}"/>
 <classpath>
<fileset dir="lib" includes="*.jar"/>
 </classpath>
</java>
</target>

<target name="test" depends="init">
<java classname="com.eviware.soapui.tools.SoapUITestCaseRunner" errorproperty="tests-failed" fork="yes" dir="${test.dir}">
 <arg line="-j -M -r -a -f${basedir}/${test.dir}"/>
 <arg value="${project.dir}/${soapui.project}"/>
 <classpath>
<fileset dir="lib" includes="*.jar"/>
 </classpath>
</java>
</target>

<target name="test-single-project" depends="init">
<antcall target="run-single-test">
 <param name="project" value="${project.dir}/${soapui.project}"/>
</antcall>
</target>

<target name="run-single-test">
   <java classname="com.eviware.soapui.tools.SoapUITestCaseRunner" errorproperty="tests-failed" fork="yes" dir="${test.dir}">
 <arg line="-j -M -r -a -f${basedir}/${test.dir}"/>
 <arg value="${project}"/>
 <classpath>
<fileset dir="lib" includes="*.jar"/>
 </classpath>
</java>
</target>


<target name="report">
<junitreport todir="${test.dir}">
 <fileset dir="${test.dir}">
<include name="TEST-*.xml"/>
 </fileset>
 <report format="frames" todir="${test.dir}/reports/html"/>
</junitreport>
    </target>


</project>



Tuesday, February 3, 2015

RobotFramework tools installation guide

I used RobotFramework for more than half a year, I really love it.
Now I shared my installation guide.

Hope this will be helpful for any  Developers who are interested in RobotFramework, but don't have Python experiences.

Set up Robot framework Tool Chai

1. Install python
   download python 2.7.6
   https://www.python.org/downloads/

 add the python installation folder to the windows PATH environment variable, for example
   C:\dev_software\Python27;
 
2. Install pip
    http://pip.readthedocs.org/en/latest/installing.html
   download get-pip.py via https://bootstrap.pypa.io/get-pip.py
   open a command window via "run as admin", type:
   python get-pip.py

   Add following into windows PATH environment variable:
   C:\dev_software\Python27\Scripts;

 
3. Install robot framework
   pip install robotframework
 
4. Install selenium2library
   pip install robotframework-selenium2library
 

5. Install RIDE

  install wxPython  wxPython 2.8.12.1
    http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/wxPython2.8-win32-unicode-2.8.12.1-py27.exe/download
             
  install through windows ride package win32 version
   https://code.google.com/p/robotframework-ride/downloads/detail?name=robotframework-ride-1.2.3.win32.exe
 
  Or install using pip
   pip install robotframework-ride
 
6. Install selenium webdriver client

   chrome driver: http://chromedriver.storage.googleapis.com/2.10/chromedriver_win32.zip

   IE driver
    http://selenium-release.storage.googleapis.com/2.42/IEDriverServer_Win32_2.42.0.zip
             
unzip them and copy the exe files in c:\webdriver directory
set them to windows path

    C:\dev_software\webdriver
             
               

7. Test
   run pip list, then you should see following:

decorator (3.4.0)
docutils (0.11)
pip (1.5.6)
robotframework (2.8.5)
robotframework-ride (1.3)
robotframework-selenium2library (1.5.0)
selenium (2.42.1)
setuptools (5.1)
 
- open dos command, type
  pybot

  then it will shows:
  [ ERROR ] Expected at least 1 argument, got 0.
  Try --help for usage information.


Documents:
- RobotFramework installation doc
  https://code.google.com/p/robotframework/wiki/Installation#Python_package_managers

- RobotFramework Selenium2Library installation guide
  https://github.com/rtomac/robotframework-selenium2library

- RIDE installation instructions:
  https://github.com/robotframework/RIDE/wiki/Installation-Instructions

- selenium2library keywords doc
  http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html  

Thursday, July 10, 2014

Using Groovy MarkupBuilder to generate XML Declaration and DOCTYPE

I found Groovy MarkupBuilder can also generate xml declaraion and doctype, with the help of groovy.xml.MarkupBuilderHelper class. Following is the example

def sw = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(sw)

def helper = new groovy.xml.MarkupBuilderHelper(xml)
helper.xmlDeclaration([version:'1.0', encoding:'UTF-8', standalone:'no'])
helper.yieldUnescaped """<!DOCTYPE note SYSTEM "note.dtd">
"""

xml.person{
  firstname("Steve")
  lastname("Zhang")
  country("Canada")
  city("Toronto")
}

println sw.toString()


And the result:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE note SYSTEM "note.dtd">
<person>
  <firstname>Steve</firstname>
  <lastname>Zhang</lastname>
  <country>Canada</country>
  <city>Toronto</city>
</person>

Saturday, November 2, 2013

Crazy English - My Toastmaster CC #4 speech

I finally finished my CC#4 speech this week. It is almost been a year since my last speech, I feel a kind of awkward.
Actually last week I went to my mentor Robert Fox's club in Richmond Hill did the exact same speech, so this is my second time,
Doing a speech in the second time is a kind of weird feeling.

My speech is about my experiences of learning English, and I got many positive feedbacks, the audiences seemed like my speech, especially I put some humour.
I realized my main problem is the pace, I spoke too fast, need to slow down, need to add more pause. I am not sure if it is because I practiced too much. And when I looked my video, I realized I have so many unnecessary movements,I definitely need to work on it.

Following is the script of my CC#4 speech.


Crazy English

"If you like him, let him learn English, because it is heaven; if you hate him, let him learn English, because it is hell."
Learning English for me is more like going to the hell.

Mr toastmaster, fellow toastmaster and welcome guests, I would like to share my crazy English learning experiences.

I came from China, English is my second language. I started learning English at the age of 9, until I graduated from university when I was 22. After I graduated, I found I got an issue - we call it 'dumb English', it means I could read in English, but I couldn't speak. The reason is we focused more on 'learning' instead of 'practicing'. We had a crazy environment: on one hand, We don't have enough good English teachers, we don't have enough chance to practice speaking, we just focused on grammar, vocabulary,grammar and reading; on the other hand, the whole country is so crazy about the English, not because it is useful in daily life, but because the students have to deal with lots of English tests: when we go to university, when we get degree and when we apply for jobs. So the main reason of learning English is to pass the tests, there is no more time to improve our real English skills.

One of the craziest test I ever had is TOEFL test. TOEFL stands for 'test of English as a foreign language'. It is very popular for the Chinese students, because this is the test you have to pass if English is your second language and you want to apply for an university in North America. To prepare my TOEFL test, I went to an English school in Beijing, That schools is famous for improving your TOEFL score in a short time. they didn't teach your the real English skills, instead they gave your tips. Those tips will help you provide the correct answer even if you don't fully understand the question.For example: in listening part, when you heard a conversation between a boy student and a girl student, the correct answer would be always the girl is better than the boy, because in TOEFL test, the girls are always smarter, working harder, keep the rooms cleaner; while the boys are always silly, lazy and make their room messy.I learned lots of this kind of tips, the thing is to master those tips, I have to do large amount of exercises, I finished 30 - 40 hour audio tapes within 3 months. Unfortunately those tips are useless in reality.

TOEFL didn't help me, I have to try another way: I remembered that was one day in 2001, by chance I heard of an approach, it was so simple but really hard - I called it crazy dictation: when you listen to an article, try to write down every word you heard, leave the blank if you don't know, then repeat listening again and again, until you fill all the blanks. After I gave a try, I realize this is the right way for me, since those blanks gave me the real feedback, once I solved them, then they became my real improvements, no cheating any more. Since then I started the dictation, I listened for 2 years, everyday I spent 2 hours at least. I really enjoy the learning process, because every day I could see my listening skills improving. The dictation was really fun, since when I finally figured out a word after I listened to it for 10 times,15 times and even more, I felt like solving a puzzle game. After 2 years, I finished 20 hours audio tapes. The dictation gave me the break thorough, both my listening and speaking skills got improved, I became more confident, I felt finally I climbed out of the English hell.

This is my crazy stories of learning English, what I learned from it would be follow the basic, step by step, and be patient, working slowly will actually makes you faster. Now I face another challenge - my Toastmaster cc manual! I am going to attack this challenge by using these principles, I hope this time it will lead me to the heaven.
 
Mr. toastmaster.

Saturday, July 27, 2013

Building my Raspberry Pi - Hardware part

I've been working on my Raspberry Pi for 3 months, I got the Model B board from my former colleague Yuriy as a gift when I left the company, I really appreciate Yuriy give me a chance to play with this tiny toy.
Now I will share the hardware I used to build my raspberry Pi.

1. Wifi Adapter, Edimax 150Mpbs
 
It works perfectly in my Raspberry Pi,no driver installation needed, the only thing I would complain is it only support 2.4G, no support for 5.8G

2. Keyborad/mouse, Logitech mk360 combo,
 I bought it from costco for $30, no driver needed, works by just pluggin in.

3. Cable
   I bought this HDMI to DVI adapter on amazon.ca for less than $2.
4. SDcard
   I used my old Sandisk Ultra II 4.0GB, I think it is class 4, and a Trascend 8.0GB class 10 for using raspbmc media center

5. Case, I bought  it from Sayal

   I like the design, transparent, the thing is once you installed your Raspberry Pi board, it is hard to take out. Besides that no complain.

6. Power adapter
   Following works:
   LG phone power adapter, Samsung Note II power adapter, and Kindle power adapter.

7. Display
   I used Samsung LCD 22-inch (DVI) and 24-inch B2430, both works perfectly.

8. Blue tooth adapter, IOGEAR GBU521

   It works on Raspberry Pi, and could pair with my mac wireless keyboard and mouse, but it takes long process to install the bluetooth package, and I seldom use it
any more, I would not recommend it.

Totally I spent another $50 - $70 to build this tiny computer, it is still a lot cheaper than building a regular one. I really love this toy.

Wednesday, June 5, 2013

Attacking the legacy code:Buiding weblogic beehive application using ANT

Recently I started to investigate on writing an Ant script to build our J2EE web application. Right now we just export the WAR file using Eclipse IDE, but we plan to adopt Jenkins for the build automation, then we got a problem. I tried Eclipse Headless build, it did not working. So I decided to use Ant script to build our J2EE web application. Our application is based on Weblogic 10.3, it uses lots of weblogic portal library, netUI, and page flow. Through several times trial and error, finally I got my ant script works. It is a kind of tricky, here I would like to share my experience, show you how to write an ANT script to build the Weblogic beehive application.

1. Setup the environment variables in your ANT script file
 You need to setup following environment variables: WL_HOME, WORKSHOP_HOME, and BEA_HOME.
 In my computer weblogic was installed under C:\Oracle\Middleware, so these environment variables will look like this in my build.xml:

        <property environment="env"/>
<property name="env.WL_HOME" value="C:/Oracle/Middleware/wlserver_10.3"/>
<property name="env.WORKSHOP_HOME" value="C:/Oracle/Middleware/wlportal_10.3/workshop" />
<property name="env.BEA_HOME" value="C:/Oracle/Middleware" />

2. Import weblogic Ant task files into build.xml
   Based on this article, WebLogic Server ships with the following Ant files for building and deploying Beehive applications:
   <WL_HOME>\workshop\weblogic-beehive\ant\weblogic-beehive-buildmodules.xml
   <WL_HOME>\workshop\weblogic-beehive\ant\weblogic-beehive-tools.xml
   <WL_HOME>\workshop\weblogic-beehive\ant\weblogic-beehive-imports.xml
 
   In my computer, the ant script folder will be: C:\Oracle\Middleware\wlportal_10.3\workshop\weblogic-beehive\ant

   I found a bug, in weblogic-beehive-imports.xml:
 
   <property name="apache.xbean.jar" value="${env.BEA_HOME}/modules/com.bea.core.xml.xmlbeans_1.0.0.0_2-4-1.jar"/>
   <property name="bea.xbean.jar" value="${env.BEA_HOME}/modules/com.bea.core.xml.beaxmlbeans_1.0.0.0_2-4-1.jar"/>

   should be changed to:

   <property name="apache.xbean.jar" value="${env.BEA_HOME}/modules/com.bea.core.xml.xmlbeans_1.1.0.0_2-4-1.jar"/>
   <property name="bea.xbean.jar" value="${env.BEA_HOME}/modules/com.bea.core.xml.beaxmlbeans_1.1.0.0_2-4-1.jar"/>

   I just copied those 3 xml file into my project folder, so in my build.xml, add following after the property definition:
 
   <import file="weblogic-beehive-imports.xml"/>
   <import file="weblogic-beehive-tools.xml"/>
   <import file="weblogic-beehive-buildmodules.xml"/>

3. Write ant target to build web application
   Use weblogic "build-webapp" ant task, it will compile the source code, and it will generate the page flow xml, specifically it will generate those xml files under WEB-INF\classes\_pageflow folder, which took me a long time to figure out.
    Please note: to build successfully, you need to put the source code under the WEB-INF\src folder.
 
   The ant target will look like this:

   <target name="build-web" depends="init">
<build-webapp
     webapp.src.dir="${build.dir}"
     webapp.build.dir="${build.dir}"
     app.build.classpath="webapp.classpath"/>
   </target>   
 
4. "Error running apt compiler" issue
   At first the ant script works in my local machine, but under windows server it failed with "Error running apt compiler", and the detailed error is like "CreateProcess error=87". After Google this error, and found out it is because the classpath is too long.
   To fix this, I checked my classpath library, and removed all the unnecessary files, and finally it is working.

Resource
1.  Building Beehive Applications

Tuesday, June 4, 2013

My Toastmaster Sergeant-At-Arms debrief

Now it comes to the toastmaster year end, and my role as SAA is almost finished. It is time for me have a debrief.

WHY I picked the Role of SAA
Last  year of this time, I just joined the Markham Toastmasters club for a couple month, I was very impressed by the highly structured meeting, I was really curious about what is the behind scene; and as a software developer I am very interested in self-organized team, toastmaster club is a good example of self-organized team, I really want to know more about it; the third reason is I thought SAA is the easiest job, if you can arrive earlier each time, then it is not a problem. Considering these reasons, which droves me to attend the executive team, take the role of SAA.

HOW I did my jobs and my achievements
When I started working, I realized I was wrong, there are lots of work - both visible and invisible jobs. At the beginning, I feel a kind of stressed, and even more the past SAA Hitesh did such a great job, he raised the bar, which made me nervous, how can I match that? My mentor Robert suggested me that just try my best, I will say I did that. I have a passion to do a better job, always try to come to the meeting at 6:30PM, this job needs focus on details, since any small mistake will cause the problem; and you have to keep multi-tasking, which means I need to do some sacrifice, focus on helping others without pay attention to the meeting.  I keep asking for help, Hitesh give me lots of tips, I really appreciate this guy.

What I am proud of myself is I applied what I learned from my career to the SAA role, for example, from Lean I learned value added system and eliminate waste - when I do my job of SAA, I keep asking my self, how can I add more value to the club? how to make it better? From Kanban, I create a Kanban board to visualize the guest list; From continuous improvement philosophy, I keep asking myself, how can I improve the process, make the process better? And from Scrum/Agile, I learned the concept of Servant leadership, which means a good leader is helping other better, removing the impediments which hold them back; all these helped me a lot to do my job.

Overall beside I did my job, I make the following achievements which I believe added the value to the club:
- Created a Kanban board using a software called Trello, which is lot easier to tracking the guest list and collaborate around the executive team;
- We stared recording video for speakers since February this year;
- Setup a facebook group for the club, trying to bring social media into club

Those are nobody asked you to do it, and neither will create benefit to myself, I don't even think about adding them to my CL manual, but I still want to do them? Why? because based on the lean thinking, they definitely add value to the customer - our club members, our job is delight customer, make them happy.

Overall I got positive feedback so far, which means my hard work was recognized.

The Benefit I got
I will say this is a great experience to me, the work itself is a reward. I can apply what I learned to the club, I had the autonomy to make changes, make improvement, and especially when you see your efforts can help others and make some influence, this is a great joy. I really appreciate I have this opportunity to bring my contribution and make our club better. Another great benefit is I have a chance to make friends, they inspire me and help me a lot, which is a great asset and will definitely help me in future.

Something BAD
The only BAD thing to me is I only make one speech this year, and my table topic skills is still not improved. Comparing to other executive members, I fell behind.
The reason is one: SAA job do take more time than I thought, and it will take me lots of time to prepare my speech, there is a conflict between these 2 things, I really admire other executive members, how can they finish 2 things at the same time?


Next step
Next year, I will focus on my speech, trying to finish my CC ASAP! I fell far behind with my fellow members, I need to catch up. I have bigger plans, but I realize the road block is my CC manual, it is the impediment to reach my goals. I really need help, I need mentor, I would really appreciate if anybody can help me.