testdriven.com Wrangling quality out of chaos

Archive for April, 2011

@Cukefy

04.29.2011 · Posted in News

I just had the privilege to participate in the Agile Testing class presented by Elisabeth Hendrickson and Dale Emery at the Agilistry studio in Pleasanton, CA. An important component of the class was a review of tools that support ATDD – we looked at Cucumber, Robot and Fitnesse. During the discussion on tools adoption, I brought up a point that many Java and C# shops eschew any external tools in favor of internal DSLs otherwise known as fluent style. Something like this:

   //use Jane and Buick sample data for this test
   PersonalPolicyBuilder policy =
     PersonalPolicyBuilder.ownedBy(Jane_Smith() ); 
   policy.addCar( BUICK_2000().withComprehensiveCoverage()
     .withDeductibleOf( 500 )
     .withMedicalLimit( 10000));
   assertThat( policy.totalPremium(), equals( 765.00)); 

In the discussion that followed, many folks felt that there is still too much Java in this code snippet and that their ability to read this test is sufficiently impeded by it. Ok then…

How about we add a bit more syntactic sugar and an annotation to to trigger the translation from Java to something a bit more readable:

  @Cukefy
  public void testAddCarToPolicy() {
  Given();
      PersonalPolicyBuilder policy = 
         PersonalPolicyBuilder.ownedBy(Jane_Smith() );
  When();  
      policy.addCar( BUICK_2000().withComprehensiveCoverage()
          .withDeductibleOf$( 500 )
          .withMedicalLimit$( 10000));	  
  Then();  
   assertThat( policy.totalPremium(), equals$( 765.00)); 
  }

and our translator will output something like:

   Given:
      Personal Policy owned by Jane Smith
   When:
      Add car Buick_2000 with Comprehensive Coverage
      AND with Deductible of $500
      AND with Medical Limit of $10,000
   Then:
     Total Premium should equal $765.00    

Is that better? Would you use something like this? Let me know at david@vydra.net or tweet me @vydra

Till next time.

BTW, if your team is considering a transition to Agile Testing, there is not better way to get started than Elisabeth’s course.

European http://weekendtesting.com session

04.24.2011 · Posted in News

On April 23rd, 2011 I participated in the European Weekend Testers online group testing session. We tested some boundaries of the Skype test chat. While the session was facilitated from Europe we seemed to be about evenly split between Europe, USA, and India. A couple of observations:

I was impressed that even though we only used Skype chat to communicate as a group – no voice – the discussion was fairly easy to follow up and I was able to stay fairly focused. Perhaps its even advantageous not to have a voice session for such activities. There was a separate shared doc on typewith.me, but it did not get much use. Since the test session only lasted one hour and the ‘mission’ was not announced prior to the session, I would characterize most of the activities we did as team exploratory testing.

What impressed me? People! There is no substitute for engaging in your profession with Awesome Collaborators! Next: Tools, tools, tools! I have never used the excellent perlclip tool before. Using Google Translate to generate interesting char sets was a good move by Petteri. In addition, our discussion turned pretty technical – we talked about sniffing network traffic with Wireshark, about possible internal representation of the Skype chat data (XML?), etc. This is something that I am always challenged to explain to folks in enterprise testing – exploratory testers can be VERY technical and still enjoy it.

We spent a surprising amount of time discussing whether testing the _production_ installation of Skype was either ethical or legal. I remember uTest running massive test challenges on commercial sites and I wonder if they had to get permission from all of them?

A few highlights:

Ben Simo: Not to be a party pooper, but is such potentially-destructive
testing permitted by Skype’s TOS?

Ben Simo: As computing professionals, we have a moral imperitive to
avoid harm to others. If we do not have confidence that testing skype in this way will not harm
anyone, we should not be testing in this way.

David Vydra: Ben brought important points…but…there is also
the ‘reasonable person’ test

David Vydra: unless we use massive data generation scripts, i.e. DOS
attack, Skype will not notice a few strings being sent via chat.

Ben Simo: You assume Skype will not notice a few string being sent via
chat. Without knowledge of what Skype does with the data, how can we know whether or not a
data sting we send with intent of finding limits will cause any harm beyond our own client.

Read more here: http://weekendtesting.com/archives/1956

Programmer/Tester collaboration example

04.14.2011 · Posted in Articles

Most testers of enterprise applications have some programming background, some even have degrees in computer science, but most of them would not qualify as professional programmers and that is the way it should be because great testers should be great analysts and competent in the skills of testing. Recently, a tester described to me how she was testing the migration from one DB vendor to another. She saved the result set of an SQL query, imported it into an editor and converted it into a query for the the target databases by wrapping each item in quotes and separating by a comma.

Something like:

joe1234
mary2234

INTO “SELECT * FROM rwm.Loginlog WHERE userName in(“joe1234”, “mary2234”);

This is certainly a reasonable test technique for this situation and the manual step of ‘generating’ the test SQL is not very difficult. Still, doing manual test preparation that does not require any thinking will take its toll on the tester and should be automated if affordable. In this case, the tester, though competent in SQL did not know how to automate the entire operation. I decided to give it a shot and time boxed it for an hour. I decided to try writing a stored procedure that generated the required SQL code. I have never seen a MySql stored procedure before, but with Google as my pair-programming partner, I was able to write it in about 45 minutes. (Caveat, there maybe a much more elegant way of doing it, but my code works and does the job)

File: p1.sql

DELIMITER |
DROP PROCEDURE IF EXISTS p1;
CREATE PROCEDURE p1()
BEGIN
DECLARE done INT DEFAULT 0;

DECLARE colValue VARCHAR(255);
DECLARE cur1 CURSOR FOR SELECT userName FROM rwm.Loginlog;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

SET @outsql = ‘SELECT * FROM rwm.loginLog WHERE userName in( ‘;

OPEN cur1;

read_loop: LOOP
FETCH cur1 INTO colValue;
IF done THEN
LEAVE read_loop;
END IF;

SET @outsql = CONCAT(@outsql,'”‘,colValue,'”,’);
END LOOP;

CLOSE cur1;

SET @outsql = LEFT(@outsql, LENGTH(@outsql) – 1);
SET @outsql = CONCAT(@outsql, ‘);’);

END|
DELIMITER ;

And you install and run it like this:

source p1.sql
call p1();
select @outsql

With this code in hand, the tester can easily modify it to suite many similar situations without needing any more help from the programmer.

Elisabeth Hendrickson (http://twitter.com/testobsessed) suggested that saving results from both databases and comparing the files using unix tools is another time-tested approach and I am sure there are at least a dozen others. The moral of the story is that most programmers would love to help you avoid doing mindless, repetitive work – just ask them for help.