[BioRuby] GSOC: Unit testing in BioRuby

Michael Barton mail at michaelbarton.me.uk
Sun May 24 22:28:07 UTC 2009


Cheers. Good luck with the rest of the project.

2009/5/24 Diana Jaunzeikare <rozziite at gmail.com>:
> Thanks  a lot Michael! It worked.
>
> Diana
>
> On Sat, May 23, 2009 at 7:00 PM, Michael Barton <mail at michaelbarton.me.uk>
> wrote:
>>
>> Hi Diana.
>>
>> You could try adding a module along these lines to your test file,
>> inside the TestPhyloXML module.
>>
>>   module TestPyloXMLData
>>
>>     bioruby_root  = Pathname.new(File.join(File.dirname(__FILE__),
>> ['..'] * 5)).cleanpath.to_s
>>     TEST_DATA = Pathname.new(File.join(bioruby_root, 'test', 'data',
>> 'pyloxml')).cleanpath.to_s
>>
>>     def self.example_xml
>>       File.join TEST_DATA, 'phyloxml_examples.xml'
>>     end
>>
>>   end
>>
>> You can then use
>>
>> TestPhyloXMLData.example_xml
>>
>> To return the path to the example test data file.
>>
>>
>>
>> The code you described in your email adds the bioruby root to the
>> library path so you can do
>>
>> require 'bio/db/phyloxml'
>>
>> at the top of your test file.
>>
>> Is this any help?
>>
>> Cheers
>>
>> Mike
>>
>>
>> 2009/5/23 Diana Jaunzeikare <rozziite at gmail.com>
>> >
>> > Hi,
>> >
>> > How does unit testing in BioRuby works?
>> >
>> > I created new file /lib/bio/db/phyloxml.rb and
>> > test/unit/bio/db/test_phyloxml.rb  I also put some sample xml files in
>> > /test/unit/data/phyloxml/ directory.
>> >
>> > How can I access the data set in data directory from the
>> > test_phyloxml.rb
>> > file?
>> >
>> > Can I give path relative path to the data file? for example
>> > "../../../data/phyloxml/phyloxml_examples.xml"
>> >
>> > I saw other test files have this code:
>> >
>> > "require 'pathname'
>> > libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
>> > 'lib')).cleanpath.to_s
>> > $:.unshift(libpath) unless $:.include?(libpath)
>> > "
>> > Is this code for that purpose?  I am not really sure what this piece of
>> > code
>> > means.
>> >
>> > Thanks,
>> >
>> > Diana
>> > _______________________________________________
>> > BioRuby mailing list
>> > BioRuby at lists.open-bio.org
>> > http://lists.open-bio.org/mailman/listinfo/bioruby
>>
>> _______________________________________________
>> BioRuby mailing list
>> BioRuby at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioruby
>
>




More information about the BioRuby mailing list