Archive

Monthly Archives: October 2011

I’ll be presenting at the inaugural South Bay Automation Meetup @ Chegg headquarters at 6:00 PM. The address is 2350 Mission College Blvd Suite 1400, Santa Clara, CA (across the street from Intel).

The South Bay Automation Meetup is an effort to cross-pollinate automation strategies between different software companies in the south bay.  It’s amazing how many interesting ideas exist out there!  In a Meetup-type setting, not only do you get to learn about the subject but you can always ask questions and add your own ideas to the theme.

During my presentation, I’ll be discussing an alternate way of automating a website without the constant maintenance needed to keep up with minor design changes (hint: bypass the web browser).

Hope to see you there!

btw, did I mention it’s FREE to attend and participate???

Here’s a link to the Meetup:  http://www.meetup.com/Bay-Area-Software-Quality-Group/events/17529888/

There are times when writing code where nothing wants to work and/or you just can’t get past a hurdle.  My advice to you: Step Away from the Computer!

More than likely, you’re doing something really lame but you’re not going to figure it out until you take a breather.  If you’re like me, you’ll probably run the problem through your head a hundred times after you step away and that’s OK.  Just make sure to physically step away and do something else – like sleep – before trying to tackle the problem again.  Another option is to run the problem past one of your colleagues who may or may not be able to help you but just speaking out the problem may help you to solve it on your own.

I ran into this today and followed the latter advice.  While explaining my problem to a PM sitting next to me (which of course required me to explain the problem in more detail), I noticed a clue that I missed that eventually led me to the answer.  I don’t want to bore you with the details of the problem or the clue but understand that “- 8″ does not equal “+ 8″.  :)

In short, my problem turned out to be PEBCaK (look it up) situation.  <sigh>

I joined the software QA ranks at PayPal in 2000.  It was near the end of the big bubble and there was still a major glut of tech jobs vs. people to fill the jobs so some VERY unqualified people were hired to fill the roles, myself included.  The role was pretty simple at the time and didn’t require a lot of technical knowledge.  Luckily, I had a really good – albeit narcissistic – manager to mentor my way into the world of blackbox QA.

Well, things have changed over the past 11+ years.  It’s rare to find QA positions that don’t require some level of programming ability.  Software QA Engineers today (often called Test Engineers) work side-by-side with developers and help build test-able products.  In other words, before a product is built, unit tests and test stubs are created that allow QA to thoroughly test it early and often.  Of course, the test engineer needs to understand the product from top to bottom to request (or build himself) the unit tests and necessary stubs.  This puts QA smack dab in the middle of the initial meetings when designing a new product.  Looking back to my blackbox days, I was always told about a new product after it had been built and expected to test it.  SERIOUSLY?!?

QA engineers today test features from every angle: web server, DB schema, CDN, S3, file system, DRM, cloud servers, co-location implications, server hardening, OS and browser compatibility, A/B tests, load, stress and performance tests, acceptance, fail over, usability, integration, etc.  We’re also responsible to not just report a bug but to dig into the code and find out what happened (or at least narrow down the search).  We need to know why a failure occurred so that we can better prioritize the bug.

QA Engineers need to understand that a bug becomes more and more expensive the longer it exists within the code base.  A bug that makes it to production costs at least 10x more money to fix than if it had been found early which is why we need to identify potential weaknesses early in the cycle.  Never has the term “time is money” ever ring so true.

I often wonder where I’d be if I hadn’t taken a few programming courses in 2004 (C++, Python, PHP).  “Would you like fries with that?” comes to mind.

There is a place for Selenium and test tools of it’s like but not to the extent that I see many companies using it.  It can be made relatively maintenance free with a bit of finessing and product and development teams that think about testing continuously.  Of course, this is usually not the case and release after release, I see more and more time being devoted to just getting the test cases to work.  You see, with an agile environment comes A/B testing, rapid iteration and many changes to the GUI.

Test case maintenance should never take so much time that new test case creation suffers.  This is an overarching problem that I find with web-based functional testing.  Since this is the area that’s constantly changing – visually, not functionally – teams should automate at this layer sparingly.  I’m a big fan of back-end automation and what little bit of front-end automation I endorse, usually eliminates the browser all together.

Essentially, you can get the best bang for your front-end functional automation by simply POSTing/GETing forms via an xUnit test framework without worrying about your test cases due to GUI changes.  There’s no reason why a functional test case should fail because a button moved on a page or an image is taking too long to load – not that the latter is unimportant but a different test case verifying that functionality should fail instead.

I demonstrated this kind of testing at past companies and recently at Chegg.  Even though my script hadn’t been used in weeks, the only maintenance needed was a change to a POST url and the addition of another parameter (both of which would have also failed with Selenium, btw).  The script is not part of the regular regression suite simply because it’s used as a helper script to speed up tedium and thus was not used for a while.

To be clear, it’s a slow process to get started automating in this way but the extra amount of time spent building the test cases FAR out-weigh the time saved in the long run.  To illustrate this, the above script was created because the Selenium automation engineer refused to automate the functionality; those web pages constantly changed and would require maintenance every week.  Besides, once you start building up a library of HTML parsers and POST/GET URLs, the time to create new test cases speeds up.

Here’s an example of how simple a test case can become after the necessary libraries are built (example in Python, of course):

#open a new liquidation cart
url = cfg.get('urls', 'openCart') % wimsBaseUrl
elements = {'universal_input':cartName}
result = CL.postHtml(url, **elements)
myTag = CL.getTagData(result, 'input', **myArgs)

The “url” is the url to POST the parameters to, “elements” is a Dictionary of the parameters being POSTed, “result” is the HTML response after the POST and “myTag” is an example of a function used to parse the HTML (check out BeautifulSoup for Python).

In conclusion, slow and steady wins the race.

I had a bunch of “fun” with Ubuntu’s xvfb (x-windows virtual frame buffer) today.  Despite my best efforts, it would randomly choose to just hang around for no apparent reason. My Python script just sat around waiting for the subprocess to be released but to no avail.

My script was supposed to load a local HTML file in Firefox and get a screen capture using PageSaver Pro and then close the browser. In some instances however, the browser would quit but xvfb didn’t. Of course, this wasn’t an issue on my Mac because I didn’t need to run a virtual frame buffer as a display is connected to it.

After much futzing around and an inordinate amount of Google searching, I was finally able to figure out a less-than-elegant for fool-proof solution to the problem.

Here’s the Python code snippet:

from subprocess import call
import os, signal


cmd = “xvfb-run ‘<xvfb arguments>’ <program to execute (e.g. firefox)>”
call(cmd, shell=True)
try:
pid = int(open(‘/tmp/.X99-lock’).read().strip())
os.kill(pid, signal.SIGINT)
except:
print ‘lock file not found’

Again, it’s not elegant but it surely did the trick!

I’ve always found it funny when I would go to a developer with a bug and get the response of “but it works on my machine!”.  My go-to response has always been, “ok, well then we should be point all of the customers to your machine so they don’t run into this problem.”

Sadly, I pulled this same stunt on myself today.  I’ve been working on a project that requires the use of Webkit to take a screenshot of an HTML page.  On my Mac, Webkit is nicely pre-installed and works great with my script but on the Ubuntu box that will be running the script regularly, I had to re-write the script to use QT4 with PyQT bindings.  Of course, it’s having issues… <sigh>

At least I can honestly say that it works great on my machine!  :)

Stinky Engineers
Thomas Edison once said that genius is 1% inspiration and 99% perspiration.  I think software testing follows a similar rule where 99% of the time, testing is tedious and boring while we relish that 1% of the time where we relish the finding of a P1 bug or complete a troublesome bit of automation.  Is it really true that 1% of our time and effort keeps me going during the other 99% of the time???

It’s pretty amazing how quickly we can forget about the tenacity of the day-to-day grind with a win here and there.  I encountered one of those “great win” moments recently after nearly 4 months of writing and verifying SQL queries.  Over lunch, a coworker mentioned to me that his team was in desperate need of someone to build a test tool to verify that the HTML5 files we are creating visually matched the PDF files that we received from textbook publishers (these files are being used for a textbook e-reader).  Without giving away the implementation details in this post, I can say that it was an awesome experience as was the recognition I received for a job well done!

The glory of that project will be enough to sustain me through the grind of building out the servers to run my code and probably several weeks after.  Yeah, that pretty much adds up to the other 99%…

Follow

Get every new post delivered to your Inbox.