Wednesday 18 July 2007

got on the train of rails

Now its finally time for me starting to read the "Agile Web Development with Reails 2nd ed" so I can be updated at bit on how this rails works, not that there is any job related interest yet, just a wish to try and learn (and to code my secret project).

Anyway to start somewhere I just downloaded ruby 1.8.6 from www.ruby-lang.org where there also is an excellent tutorial called "ruby in 20 min" try it, its nice and fast (link).

Unittesting private methods

I found something that throws an exception in a private method, to make sure I correct it, and it keeps corrected, I would like to write a couple of tests for that method. But its private, so how do I go..

I read the following article, which do describe it for Java, but the same problems apply for vb.net (except I dont know if .net reflection allows one to access private methods like java)
Testing Private Methods with JUnit and SuiteRunner

As you will see, there is no nice way to do it, so I think I will try to rethink the design, and then see if I really need to test a private method.

Finishing with a quote:
In general, you don't want to break any encapsulation for the sake of testing (or as Mom used to say, "don't expose your privates!")

By Dave Thomas and Andy Hunt, in their book Pragmatic Unit Testing.

Monday 16 July 2007

Configuration of the tests

I find myself in the dilemma of having to run my tests in a new database with a new set of data. This should not be an surprising event, but it does require that I "update" my tests to the new reality. Cause I cant use the same keys, as before.

So how does one solve this problem. I thought up two different solutions, where one is pretty nifty but time consuming, and the other is more slow, but probably the one I am going for.

The first one, is to circumvent the util being tested, and access the database directly, and auto generate the needed row keys ect. here, one could use the loved (and hated) datasets of .NET

The second more boring one is simply to make an xml file, containing all the configuration- the key to be used for testing get methods, the search critia for the list search, and the expected size of the result, ect. For this solution one misses the ease of java's properties library.

After surfing the Net, I found this article on CodeProject "Managing configuration settings persistence in .NET applications", which describes how to read a xml file into a dataset. I will try that solution.

This post will be updated...

Monday 9 July 2007

logging in client proxy

I have found myself wondering what is a good logging strategy. There are several levels to consider, when you are implementing a client/proxy for an existing server. So far there are two major scenarios, where its interesting to log, one can be said to be sub case of the other.

-Regular logging where you are just interested in logging the fact that there is been send a request to the server, when, what and who.

-Debug logging where its interesting to look at the execution path through the client code. which will pinpoint anything strange. This can of cause also be done just by stepping through the code, but I would be much easier if one were able to insert enough debug writes to support an easy identification of the exceptional behavior.

Since the regular logging of the 3 w's is included in the debug logging, my plan is to include this info as a normal debug output, and then just filter it, to make the prober log file which is an requirement.

The overall strategy (using log4net) is the following levels:

- log fatal if the client losses the connection to the data source
- log error if there is thrown an exception or an err code is returned.
- log info when a workflow is finished. (for example the data written in a dump file)

More posts will follow of how to set up everything...