Tuesday, June 16, 2015

Fearless change - my presentation in Toronto Agile Open Space 2015

On June 6th I participated the Toronto Agile Community's open space event. it is a whole day meeting following the format of open space. This is my second time, and I feel more confident to contribute a presentation. My topic is called "Fearless change - how to drive technical changes in large organization". it covered Linda Rising's book "Fearless change", and how I get inspired and applied some patterns to guide me build the RobotFramework community in TELUS. Now I would like to share my experience of this presentation.

Preparation
I treated it seriously because I feel this is a great opportunity of practicing my public speech. Thanks Toastmasters club gave me the courage.
 - A month before the meeting I asked the advice from Joanne Stone, she gave me the positive feedback, also provided some tips.
 - On the day before the meeting, I printed out the 10 copies of 48 patterns list, and 10 copies of the colorful mind maps based on the book.
 - I brought the paper book with me.
 - I brought the mind map of my presentation note.
 - I wrote down the names of the patterns on the Post-It note and brought with me.

Presentation
Before the meeting I met Paul and asked him some advice. also I met my colleague Dimitar, I asked him help me facilitate my presentation. It turns out he was one of my best audience.

During the presentation, I introduced the book of "Fearless change" written by Linda Rising. I tried to provide the answer of this scenario: when you learn a new tool or idea from internet or conference, how you can promote them in your organization, where can you start?  The answer is using the 48 patterns in the book, they are easy to follow, very concrete and actionable. I can apply to anybody who aspired to bring changes to the team or organization, especially those are powerless, no official titles. I gave the example how I use some patterns to guide me build the RobotFramework automation testing framework in TELUS. I covered the following patterns:
- Evangelist
- Just Do it
- Connector
- Early Adopter
- Study Group
- Ask for Help
- Involve everyone
- Dedicated Champion
- Do food

One of my favorite pattern is "Just Do it" - it means don't wait for permission from your boss, just do it, DON"T LET YOUR BOSS KNOW. when you get experience and successful, then tell your boss. My experience is if you ask permission to your boss first, he will ask you several questions: What is the benefit? Pros and cons? How much time/money it will take? But since it is at the beginning, you will not able to answer those questions, then you boss will likely say NO, once  he say NO, then you will not be able to work on it. This is Catch-22 problem, to prove its benefit, you need to do it first; to do it, you need to prove it is valuable. So the solution is "Just Do It"!


Retrospection
The feedback from Dimitar was positive, he likes my topic and hand out of the mind map. I believe I am the only one to prepare the materials hand out to the audience.
I found I can still make it better: firstly I chose the wrong room, which is too far from the main hall, limited my audience; secondly I need to provide more information, like the website of the book, and url of the mind map image, and my personal email address, etc.

Next Steps
I felt very good because I feel I can contribute something to the Agile community. A great starting point. In future I am interested in the following area, and hopefully I will provide more topics for the next year:
- Software Craftsmanship movements and coding dojo
- Self-organizing team, what/why/how
- build learning organization
- build cross functional team
- To sell is human (from Daniel Pink's book)

Resources
1. Linda Rising's book page 
2. The url of fearless change mind map

Friday, May 8, 2015

How to submit a form using javascript in ATG

Today I spent lots of time to figure out how to submit a form in ATG platform. I tired many times and with the help of Google, I finally find the solution,

1. make sure to set type="hidden" to the input field of the formHandler  handleXXX method, like this:

<dsp:form id="myForm">
   ....
  .....
   <dsp:input type="hidden"  bean="MyFormHandler.handleMethod" value="" />

</dsp:form>


2. in  your javascript method, you just need to call:

$(#myForm).submit();


I found when I typed type="submit" for the input field, and  the handleXXX method is never called when the form is submitted through the javascript.

Resources:
1. https://community.oracle.com/thread/2471843
2. http://stackoverflow.com/questions/29300501/atg-formhandlerneed-to-set-some-values-before-calling-the-handle-method
3. http://www.mkthakral.com/j2ee/oracle-atg/atg-formhandler-ajax-call-using-jquery-json/

Wednesday, May 6, 2015

How to mock a for loop using mockito

Today when I tried to use mockito to write unit test cases, I found I need to mock the for loop operation. Then I found the solution from here in stackoverflow: the basic idea is to mock the iterator class and collection class, and base on your situation, you need to set the expectation of iterator.hasNext() and iterator.next() method.

The following code is copied from the above link:

Saturday, May 2, 2015

Groovy's powerful collection methods

Recently I just realize Groovy provides some handy methods for collections.

Permutations

Combinations

Subsequences
Intersect

Friday, May 1, 2015

Review of the talk: "Complexity is Outside of the Code"


Broadcast live streaming video on Ustream


Yesterday I watched the video: "Complexity is Outside of the Code" by Dan North and Jessica Kerr at craft conference 2015.  Here I summarize what I learned.

Learning
  • Learning is a first class task.
  • Follow the process: explore, evaluate, familiarize, understand and validate
  • Lean startup's "build-measure-learn" cycle, nothing should be built without any reason.
business impact <- learn <- measure <- test <- code
Dan uses the Kanban's pull based concept to describe the above concept: for example test pulls the code, business pulls the learn. This drives me to think more about TDD, in TDD we believe we should never start coding without a failing test.(Uncle Bob's 3 laws of TDD),  which is quite similar with the lean startup concept: "nothing should be built without any reason",  in TDD, the failing test is the only reason for coding, which means the failing tests pulls the code, Bingo! Now I understand why Kent beck said TDD is Kanban for code


The Goal of software development
The goal of software development is to sustainably minimize lead time to business impact

Develop a supportive community
  • Nurturing a supporting team is vital within software development
  • It is OK to point out bad things and not have a solution
  • Reduce specialist silos, encourage becoming generalist
  • Developing a supportive community, contribute open source to other teams

Resources
http://www.ustream.tv/recorded/61439914
http://www.infoq.com/news/2015/04/north-kerr-complexity-code
http://www.slideshare.net/jessitron/complexity-is-outside-the-code

Wednesday, April 29, 2015

Regular expression: you should not use dot to match any character in Java/Groovy

Recently I just realize that in if you want to match "any character" in  Java/Groovy, you should not use dot match (.).

The reason is: dot match only works for single line text, will not work for line breaks.  For the multiple lines text matching, the solution to match any character is using [\s\S].

Please refer this article for details.

For example, following code snippet is used for stripping the javascript code in the text

Source code:

Learning Scala 1: swap array elements

Here posted my solution for the exercise 2 and 3 of Chapter 3 of page 39, in the book "Scala for the impatient".

Exercise 2.  Write a loop that swaps adjacent elements of an array of integers. For example,
Array(1, 2, 3, 4, 5)  becomes Array(2, 1, 4, 3, 5) .

Solution:
Exercise 3.  Repeat the preceding assignment, but produce a new array with the swapped
values. Use for /yield.

Solution:
Note: I realize you can not write java style for yield statement, like if ( i%2 ==0 ) yield s(i+1)

Monday, April 27, 2015

What I learned from Agile Engineering training

Last week I took the 3-day "Agile Engineering Training" in TELUS, thanks a lot to our trainers from LeanIntuIt - Shawn Button and Declan Whelan.  I learned a lot from them.  The course covers TDD, Simple Design, SOLID principles, refactoring and dealing with legacy code.  The fun part is there are a lots of coding Kata, like Bowling Game, Gilded Rose, etc.  I am so glad to have an opportunity to learn those stuff, even actually I learned them since 10 years ago, this time I feel  this training is a kind of a review of what I learned since I decided to be a software craftsman.

Here is the mind map summarized of what I learned.


Add some thoughts:
  1. TDD/SOLID principles/Refactoring skills become more critical and in an Agile/Scrum team,  you have to be great, to be better so that you can deliver faster,  your code will be easier to change, easier to maintain;
  2. Simple Design -  it is summarized by only 2 points: fixing names and removing duplication. Combining with TDD's Red/Green/Refactoring cycle,  it means just repeating this 2 things with test cases, your complex code logic design phase will turn into many tiny steps which just renaming and removing duplication; if you can do it fluently,  the effort of thinking hard before hand becomes simple physical typing movements - which means you can design the code without thinking too much. This conclusion is so striking.
  3. Refactoring -  When I tried the Kata Gilded Rose (a simpler version which have all the tests before),  I really sense the power of simple design - refactoring by doing renaming and extract methods, then the business logic gradually emerged, and design pattern is emerged. For me it means as long as you have all the test cases, then you can refactoring the code without need to understand the business logic, and business logic will be more clear after you refactored.  That is another aha moment for me. Looks like code quality is a separate attribute beside the domain knowledge. If we apply this to code review, it means the good code should be enough understandable without understanding the business background first.

Resources:
  1. Four Elements of Simple Design, by JBrain
  2. Kata: Gilded Rose, this is a great Kata about refactoring, it worth trying more times

Thursday, March 19, 2015

Example to execute RobotFramework test cases using maven plugin

I spent some time using maven plugin to run the RobotFramework tests. It is OK, run as expected.
But I feel it is a kind of restrictive.

Here I post my one maven pom.xml example.

For details, please check my github source code:
1. https://github.com/stevez/robotframework-maven-plugin-example
2. https://github.com/stevez/robotframework-java-keyword


pom.xml

Execute RobotFramework test cases using Gradle script


I did some research for RobotFramework using maven plugin. But I don't like it. it is too restrictive.Today I tried to implement a Gradle script, it is working, surprising easy.  Here is the code sample.

For details please refer my github repository.

build.gradle

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