Archive for January, 2009

Today I was looking on MSDN and came upon a blog entry of J.D. Meier about 8 new big trends. I must say that I agree and I want to share them also here:

  • Analytics is Hot.  “The 21st century is all about math: some of the most unique, innovative ideas are emerging with these types of analytic projects. This is where the next billion dollar industries are being born.”
  • Small is the new R&D.  “Today, the global R&D process has changed, and small is big. The global, infinite idea loop allows topic experts to share their latest research and insight with their global peers on a continuous basis. It’s a fundamental transformation in which most new scientific discoveries now percolate from the bottom up.”
  • Attitude and Amusement. “The fact is, you’ll need them. That’s why workforce engagement is the big issue — you’ll only be able to get the staff you need if you can keep them active, engaged, interested and amused. A entirely different workplace concept that is radical, yet necessary.”
  • Time Disappears.  “The major trend going forward is the collapse of time. There’s no time to plan anymore – there is just a need for action. While we still need budgets to manage and control, they’ll have to be constantly adjusted to deal with new realities. In this context, volatility is the new normal : the concept of risk management, for example, is transitioning quickly to one of risk containment.”
  • Resistance to Change Retires.  “The coming generation of senior management aggressively pursues and implements new ideas. While the first is reluctant to embrace new business models, the next steamrollers them. Expect velocity!
  • Careers End. “Your paycheck will come from: the global, itinerant, part-time, skills-for-hire economy.”
  • Knowledge & Skills Banks.  “The capital of the 21st century isn’t financial : it’s experiential knowledge that is extremely scarce and specialized.”
  • Interactivity Redefines.  “Every industry will soon be transformed by the forthcoming era of “pervasive connectivity.”  Essentially, every device and thing around us is about to become plugged in — leading us to an era of interactivity and connectivity that is mind-boggling in scope.”

Comments 1 Comment »

One of the challenges of today’s projects is automatic tests. When we speak of automated testing we always target repeatability, meaning what we test today we must be able to test tomorrow and later. This is easy for database independent applications but when your testing functionality that modifies data you always find yourself wondering how can you ensure that when the tests start you have correct data.

Just to exemplify we will give an example. Suppose you have a table User with fields Id and Name. Your functionality needs to make an insert into this table but only if a user with the same name does not exist. You make an NUnit that tests the insert, when the tests runs a new user is inserted. But what happens when you run the second time the test? Well the insert will not execute as the user already exists. To avoid this situations you have 3 choices:

  • run a script at the end of the test that will clean up any existing data (you can do this also at the begining of the test). The main problem with this is that it is hard to maintain, especially when the database changes or there are many foreign keys involved.
  • restore a fresh copy of the db at the beginning of the test so you always have the same initial data. This is time consuming and the initial state of the database might change over time so you might have to manually maintain the “fresh” database.
  • use the rollback mechanism of the database.

If we are using NUnit and SqlServer the third choice is an easy one both in implementation and maintenance. There is a mechanism provided by TeamAgile which lets you specify that a test should have the data rolled back when the test ends. The idea is simple. When the tests starts, it informs the database that all the operations in the current thread context will be executed in a transaction and at the end it will instruct the database to do a rollback. The maintenance is eased because the database you use can be a copy of the live database and this suffers no data changes from test to test.

Now we get to the hard part. NUnit test data rollback is solved but lately all big web application also use automatic tests for the interface. The tools vary: Selenium, QTP, WatiN (our choice) or others. Now for this tests data rollback cannot be used like in the case of NUnit because each request gets it’s own thread context and all the other methods have their problems as stated above. So we get to the same problem. How can we do data rollback in automated web tests?

The solution I chose is easy, but depends on the data access layer implementation. For example we have a single point where SqlCommand’s are created and that is good because we can use transactions. The idea is simple; any time a database call is made we check if we have a transaction started and if so then we will execute the call within the existing transaction. But this is implemented in the data layer and our tests are done on the interface layer and we have to somehow connect them.

Create a special page where you  have two buttons and a textbox. One button is for starting a web transaction and one for rollback -ing a transaction. When the start button is pushed we make a call to the data layer to create a web transaction. This looks in a dictionary and gets us an unique id (i.e. an int) which will identify our transaction and this id we will show in the textbox and our tests records it for later use. Then we do our tests in the web pages like usual. When we finished we go to the same page enter in the textbox the transaction id and instruct to rollback.

I will post later some code to this so stay tuned …

Comments 1 Comment »