Sunday, May 30, 2010

start making the unit tests

As I say in my proposal, I started creating the unit tests for BioRuby.
In BioRuby library, 142 files don't have the unit test files.
I will create the unit test for the files that don't use external libraries or softwares in them by next Sunday.
Currently I create unit tests for the files in db directry (I know I'm late..).

Monday, May 24, 2010

rcov and heckle

rcov checks line coverages.
Heckle is a mutation tester.

Thursday, May 20, 2010

What I have to survey

Difference between 1.8.7 and 1.9.2. How to overcome the difference
classification of the methods in terms of dependency on other libraries
The way of the test
The way of writing the unit tests. leaning what behavior I have to check and how do I check them

Tuesday, May 18, 2010

How to detect classes not having the unit tests.

Only part of class files have the equivalent test files In BioRuby.
In order to see a whole coverage of the unit test to the all class files with rcov, I have to develop the empty test files for the class files not having them.
The process is as follows.

First, make sure which files in the lib directory don't have the equivalent test files

Seconde, prepare each test file in witch the equivalent lib file is required.

Third, execute rcov to visualize the whole coverage

Sunday, May 16, 2010

About Code Coverage

This page says that "Code Coverage" is divided into the three phases, C0, C1 and C2.
The following are the summaries of the three phases to one program.

C0 is How many lines the test code checked.
C1 is what percentage of the conditional statements the test code checked.
C2 is whether the test code checked all the likelihood of the procedures.

In the case of Ruby, you can visually check C0 with rcov.

Saturday, May 15, 2010

How many tests dose BioRuby have?

Bioruby has 235 files in the lib directory and 108 files for the test.
Result from a investigation, the 133 files in the lib directory don't have the test files which are the same names as them.
On the other hand, the 102 files in the lib directory have the test files.
As for the 6 test files, it is unclear which files they match.
(There are 9 .rhtml files in the BioRuby, which don't have the files for the unit tests.)

Tuesday, May 4, 2010

Tips to keep compatibility between various versions

For the purpose of maintaing compatibility between Ruby 1.8 and Ruby 1.9, "Ruby Best Practices" suggests better ways as follows.
write codo against Ruby 1.9 first and then backport to 1.8

In order to avoid writing too much legacy code, we seem to have to write code supporting the later version first. It cannot apply to my project because BioRuby has already support the earlier version.

attempt to find a way to write code that runs natively n both Ruby 1.8 and 1.9

Avoid implementing redundant code or modifying core Ruby code as much as possible

consider backporting the necessary functionality to Ruby 1.8

If a method used in the library is different between Ruby 1.8 and 1.9, you should create new methods in classes of one version for the compatibility.

Introduce a helper method that behaves the same on both versions

For example, you may add Enumerator to String of Ruby 1.8. That provide the same behavior as "lines" method of Ruby 1.9

use brocks for the version checking

Don't use a conditional statement. Use the following code
def hoge(bar)
ruby_18 {...} || ruby_19 {...}
this way centralizes incompatibility.

reference: Brown G. Ruby Best Practices. O'Reilly Media, Inc. 239-249; 2009.