Wednesday, May 08, 2013

Career advice for testers

Here's a blog post that has taken me a few years to create.

There was a site called prizes.org. The idea was that people can post questions and responses were graded for their merits by the people posing the question. In exchange for a good response, you could earn money. In this case, someone asked the following question:
Searching for projects in test engineering to improve my technical skills
Test engineering has long been a passion of mine. I dabbled in it in school and has worked as a full time software test engineer since. I have no interest in management nor do I want to become a developer, I'd like to focus purely in the testing field. 
In the last 4 years, I've been so busy with my day job that I haven't had time to improve on my technical abilities outside of work. I want to take this opportunity to offer a prize for the best recommendation on part time gigs or projects that will challenge me mentally, sharpen my skills and push me to learn new things in the field. I don't mind if there's no compensation involved, I'd really like this to be a learning experience.
Google owned prizes.org. Like many of their other properties, it was taken down and its content removed. Rather than it being lost forever, I thought I should post it here.

The following answer was created by me and it also 'won' the competition; a whole $20. Apparently money does occasionally motivate me. :-) Anyway, it was worth something to someone once; I hope its worth something to you too.

Below is my response (circa 2011, I think):

Personally, I think your best options are to do the following:
  • Meet people: if you want to talk to other testers, http://weekendtesting.com/ is a great place to challenge your skills and meet people
  • Take a course: join AST (http://www.associationforsoftwaretesting.org/training/courses/foundations/) and take the foundations course. Great way to meet people and learn/add to your skillset. Its free once you join the AST and membership is only $80 US
  • Read some books: Depending on your perspective, find a book and read it. Read anything, fiction, blogs, etc. Anything from Gerald Weinberg or Andy Hunt would be excellent. Find your own context. My recommendation, stay away from purely technical books like "learn C++". I'm currently reading "How to Break a Terrorist" (http://www.amazon.com/How-Break-Terrorist-Interrogators-Brutality/dp/1416573151); amazingly useful when talking to developers!
  • Practice! : http://testing-challenges.org is a great place to actually try out some of the skills you have learned. Alternately, join uTest - from my experience, you get to use all your new found skills in a safe environment; and you can make money to boot.
  • If test automation is your thing: Join either an open source group and do some of their testing (see Github, bitbucket.org, SourceForge). If you don't know how to program, try Ruby as your first language. There's lots of web testing frameworks (Selenium and Watir). Remember, test design before coding... ask yourself what you are trying to test, then design the test. Maybe it can be automated, maybe it can't. Good test design is the key. See "A Practitioner's Guide to Software Test Design" (http://www.amazon.com/Practitioners-Guide-Software-Test-Design/dp/158053791X). Older book, but still really good.
  • Context Driven Testing Y! list. Lurking is good. To that end, if you are a AST member, try the new forums. Maybe there's something there.
That is easily enough to keep you busy for a year. For the last few years, I have been trying all of these and found them immensely useful. In fact, there are two more things that could be added to the list. Going to conferences of your peers and writing a blog. Both of these take a lot of money or a lot more time. Both require you to be self directed. My suggestion, follow through with one of the the points I mentioned and you'll be better suited to do the conference/blog thing later.

Frankly, don't do the "get a certification" route. there's lots of "experts" that suggest it is a title without meaning. See:
I would agree with them. Certifications are mostly memorize and regurgitate. Not terribily useful if you actually want to improve your technical skills.

JSON parsing in iOS, using the Tiny Tiny RSS API

I saw a recent question posted to reddit a few days ago. It was around the idea that there aren't any good tutorials on how to take JSON data and parse it in iOS. Since I'm a newbie to iOS, I decided that it might be a good problem to solve. Before we start, take a look at https://gist.github.com/kgdesouz/5542543/.

How the heck do you connect to a JSON API that is remote (in iOS)?

Using curl, its easy. Using iOS, there's a few more steps. First we need to put our data into some sort of dictionary (well, at least that's what I wanted to do). Inside the viewDidLoad method, you can just use NSMutableDictionary. This data will need to be serialized afterwards in order to prep it to be sent to the API.

    NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithDictionary:@{
                                       @"op" : @"login", @"user" : login, @"password" : password
                                       }];
    [self fetchData:dictionary];
    [self getCategories:_sid];
Then we need to serialize the data. The magic is done in the fetchData method. Actually, all the heavy lifting is done the the fetchData method, let's break it down a little.
- (void)fetchData:(NSMutableDictionary *)dictionary
{
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization
                        dataWithJSONObject:dictionary options:NSJSONWritingPrettyPrinted error:&error];
    
    
    if ([jsonData length] > 0 && error == nil){
        NSLog(@"Successfully serialized the dictionary into data."); NSString *jsonString =
        [[NSString alloc] initWithData:jsonData
                              encoding:NSUTF8StringEncoding];
        NSLog(@"JSON String = %@", jsonString);
Now that we have a serialized object, we can now get it ready to be sent.
        // create the connection and send it to the server
        NSString *requestString = kTinyTinyRSSURL;
        
        NSURL *url = [NSURL URLWithString:requestString];
        
        NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
        [req setHTTPMethod:@"POST"];
        
        NSString *dataString = jsonString;
        
        NSData *requestData = [NSData dataWithBytes:[dataString UTF8String] length:[dataString length]];
        
        [req setHTTPBody:requestData];
        
        NSURLResponse *theResponse = NULL;
        NSError *theError = NULL;
        NSData *theResponseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&theResponse error:&theError];

The money here is theResponseData, it allows you to POST the data to the server. Once you have sent the data, you will get back a response, so you need to deserialize that back into something useful. I'm putting it into a NSArray.
 
        //deserialize the response into something usable
        NSDictionary* json = [NSJSONSerialization
                              JSONObjectWithData:theResponseData //1
                              options:kNilOptions
                              error:&error];
        
        NSArray* validResponse = [json objectForKey:@"content"]; //2
        NSLog(@"content: %@", validResponse); //3

That's basically it. fetchData is reusable, so you can now use the same method to make other JSON queries. As per the gist, anyone should be able to use the code to connect to a JSON API.

Note: I mashed together a lot of this code from:
A few more thoughts about this little piece of code:
  • My full code snip can be found here: https://gist.github.com/kgdesouz/5542543/
  • The code was meant to be quick and dirty. I didn't really follow the MVC, since really I didn't need the view or the controller, just the model. I wanted everything to go to stdout (to keep things simple). I basically just looked at some tutorials and tried to integrate it. 
  • There's no GUI component required. Without too much effort, anyone should be able to use the code for any JSON calls, with a little tweaking.
  • There is a lot of clean up required. I'm still playing with unit testing in this language. Specifically, JSON unit testing. Its a little different since I need to figure out how to reset the JSON. I will probably create a JSON mock object to do this. 
  • I totally didn't use getter and setter methods here. I know I should, but read the first bullet point; quick and dirty.