Saturday, June 16, 2012

When lives depend on tests...

@jmarnold is speaking on testing at #austincodecamp on Twitpic

One week ago, I saw Austin's Josh Arnold, the CTO of Surgery Logistics (the developer, not the recruiter... I've interviewed for both), speak on testing at Code Camp! His domain has to do with whether or not surgeries are scheduled on time and whether or not an emergency room will be prepped for an arriving individual, so there really is no room for error as he is writing code that lives depend upon! Who better to talk about testing, no? Some bullet points:

  • Regression test everything! If you have a test that runs a swath of steps be sure the individual steps all get their own tests.
  • Keep your code DRY but your tests damp. DRY is the rule "Don't repeat yourself" ...and you should ignore it in your tests. It is better to have code copied all over the place in test than to have test logic abstracted out of the test itself. Authentication credentials are an exception. Do not copy these about.
  • Write your app firstly without a database! Get the core logic under test, then incorporate hydrated data!
  • It is alright to have a fast build/slow build split in testing. The fast build will contain vital tests run at every demonstrable update. The slow build will be more comprehensive and will run daily as part of the automation process. The slow build will test everything end-to-end.
  • Use front doors when you can. This means testing through public methods and not using reflection to test private methods. This means fabbing data with Selenium scripts in lieu of SQL scripts or C# code.
  • If you need to pause to wait for something to happen, it is better to run Thread.Sleep(X) over and over again in a loop in tiny increments until the desired effect occurs than to try to specify a length for napping. The former approach is easier to maintain.
    the Until method runs Thread.Sleep over&over in tiny blip... on Twitpic

No comments:

Post a Comment