February 3, 2011

A Guide Through the Layers of Automated Testing

 

With automated testing comes many different layers of testing. For new developers this can be a bit overwhelming. Take for example the other day at work when a developer came to me and asked what type of test should they write for a code change they did.

This question got me thinking, with all the different layers of testing out there, how does someone new to automated testing know what tests to create?

So I decided to sit down lay out what the different layers of testing are and when you should use them. This isn’t a complete list, however I feel this is a good base for a new developer to get started in automated testing.

Test Types

  • Unit test – Testing an individual method’s logic, by removing all outside dependencies. You would use frameworks like NUnit and VS Unit Testing Framework to accomplish this.
  • Integration Test – Testing two or more methods together, testing the dependencies between the methods. You would use frameworks like NUnit and VS Unit Testing Framework to accomplish this.
  • Functional Test – Testing a scenario end-to-end from the presenter to the database and back again. This type of test tests the entire application just below the GUI. You would use frameworks like Cucumber and MSpec to accomplish this.
  • GUI Test – Testing the user interface of a form. GUI test should just test the GUI, not the underlying business logic. You would use frameworks like Selenium and Coded UI Tests to accomplish this.

When to Use

Here are some scenarios you may encounter and what tests you would use.

Method Change in Service Data Access Layer

  • Unit Test - need to be written against the method
  • Integration Test (Optional) – written to verify that the data coming back from the database is valid

Method Change in Data Access Layer

  • Unit Test – need to be written against the method
  • Integration Test – written from the data access layer to the service layer and below

Method Change in a Presenter (MVP model)

  • Unit Test – need to be written against the method.
  • Integration Test – written from the method to the data access layer and below.
  • Functional Test (Optional) - If the method is in a presenter, then a cucumber test will need to be written that will do an end to end test from the method.

Change to a Form (Strictly a UI change)

  • GUI Test – against the change.

Conclusion

Deciding to begin testing you code is a very rewarding experience. It can also be a very overwhelming experience. Armed with this information I wish you well on your wonderful journey into automated testing.

January 17, 2011

Review of The Complete Android Guide

I am not much for book reviews, but I wanted to share my thoughts on this particular book. I just finished reading The Complete Android Guide and I have to say it is a must read for anyone getting an Android phone. This books covers all the basics of the Android system. From the home screen and notifications to music and photos, it covers it all. My favorite part of the book were the tutorials. The book has tutorials on numerous items including: how to setup your phone, great app alternatives for your phone, and how to save your android battery.
The book is written in such a way that you could read it cover to cover or just skip to the area you need some info on.

Get the book from here or you can read the lifehacker.com article about it here.

December 23, 2010

Installing Ruby Gems When On A Domain (Errno::ENOENT)

 

As someone who is new to Ruby I really love the idea of installing what you need for the language through gems. However, when I am at work I am on my company’s domain and when I try to install a gem I get the following error:

ERROR:  While executing gem ... (Errno::ENOENT)   
    No such file or directory - H:\

After searching for a solution to this problem, I believe I have found one.

The problem stems from the fact that logging into my domain at work changes my  %HOMEDRIVE% and %HOMEPATH% environment variables to my networked H:\ drive. To solve this problem you need to change your gem.bat.

The gem.bat file is located in your RubyFolder\bin folder. I would suggest that you first make a copy of the original before any tweaking of this file. What you are going to do is modify this file so that it changes the %HOMEDRIVE% and %HOMEPATH% before it tries to install the gem and then, when it is done, change those environment variables back to the original values. Below is an example of what you want this file to look like when you are done.

@ECHO OFF
SET _HOMEDRIVE=%HOMEDRIVE%
SET _HOMEPATH=%HOMEPATH%
SET HOMEDRIVE=C:
SET HOMEPATH=/Ruby192
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Ruby192/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
SET HOMEDRIVE=%_HOMEDRIVE%
SET HOMEPATH=%_HOMEPATH%

In the above example, Ruby192 is where Ruby is installed.

So if you are stuck behind on a domain and cannot install a much needed Ruby gem, this solution will get you back in business in no time.

I cannot take credit for this solution so here are some places where I found this solution