theres got to be a better way to test this...

Discussion in 'Ruby' started by serialhex, Jun 4, 2011.

  1. serialhex

    serialhex Guest

    [Note: parts of this message were removed to make it a legal post.]

    ok, so i'm writing some tests to check if requiring some files will work
    (right now it's all sorts of broken, but thats besides the point...)
    anyway, my (rather simple code) is this (so far):

    # some tests to see if the shogun libraries are loading properly

    require 'test/unit'

    class TestLibs < Test::Unit::TestCase

    def setup
    @libs = %w{ narray Classifier Distance Evaluation Kernel Preprocessor
    Structure Clustering Distribution Library Regression }

    def test_load
    @libs.each do |lib|
    assert load_lib( lib ), "ERROR!!!!! #{lib} didn't load!!"

    def load_lib lib
    return require lib
    rescue LoadError
    return false


    # end testing good-ness!!

    so, this works-ish. NArray loads, and throws no error, but when Classifier
    tries to load, the assert fires & the whole method stops, so my output is:

    # moar kode stufz

    $ ./test_libs.rb

    Loaded suite ./test_libs
    Finished in 0.465465 seconds.

    1) Failure:
    test_load(TestLibs) [./test_libs.rb:15]:
    ERROR!!!!! Classifier didn't load!!

    1 tests, 2 assertions, 1 failures, 0 errors, 0 skips

    # no moar kode stufz

    i was wondering if there was a more elegant way to do this other than
    writing a bunch of ... IDEA!!! ffs!! idea is epic fail! ['twas to us
    metaprogramming to make the methods, but apparently it wont automagically
    run anything but test_* stuff ;( ] ok, so yeah, anyone have any ideas??
    thanks in advance!

    -- Linus Torvalds' follow-up to a question about Linux
    serialhex, Jun 4, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.