From: Nick Sieger Date: 2008-07-16T13:49:32+09:00 Subject: Re: Is it possible to dynamically extend Test::Unit test cases? On Tue, Jul 15, 2008 at 7:39 AM, David Mitchell wrote: > > The only problem was the "scaffolding" code; apparently business users > are incapable of writing/extending code that looks like > > class Testcases < Test::Unit::TestCase > def test_1 > <> > end > def test_2 > <> > end > ... > end > > but they are capable of creating a bunch of test cases in individual > files that contain nothing but the DSL commands. They'll use e.g. > Notepad to create test cases in individual files that look like: > login('fred', 'password') > click_tab('Reports') > ... > > Fine with me - I just work here... > > So now I've got a situation where we're going to have business users > generating loads of test cases using our DSL (without any of that > nasty complicated Test::Unit::TestCase stuff), saving them in flat > files, and we need to run be able to run some unspecified number of > test cases that will change over time. What I need to be able to do > is something like: > > Dir.glob("app_test_cases/**/*.app).each do |test_script_file| > < wrapper around it and eval it>> > end > > That's no problem - I've got most of this working already; all I > needed was the way to dynamically add new test cases, and you've now > given me a way to do that. I'll have a play with it tomorrow. If you haven't already, you might look at systir [1] -- does almost exactly what you're describing. It's a little old, and perhaps not maintained much, but it could give you an idea of how to do the test/unit testcase definition more cleanly. /Nick [1]: http://www.atomicobject.com/pages/System+Testing+in+Ruby