buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rhett Sutphin <rh...@detailedbalance.net>
Subject Re: Pre test task
Date Thu, 24 Mar 2011 04:03:29 GMT
Hi Stu,

On Mar 23, 2011, at 9:50 PM, Stu King wrote:

> How would I specify a task to run before / after running my tests for a
> project definition? I am using JUnit to run some component tests against a
> back end service. I have a Rake task I can call to start / stop the
> service.
> 
> Say my definition looks like this:
> 
> define "document" do
>   package :jar
> 
>   task :start_service do
>     #start some service
>   end
> end
> 
> How would I call :start_service before running my unit tests?

define "document" do
  # ...

  test.enhance [:start_service]
end

This adds :start_service to the prerequisites list for the test task. This the generic way
to do what you're asking -- ensure that one task is run before another. According to the docs[1],
the unit test infrastructure has special support for setup and teardown blocks; it sounds
like that might also work for you.

Rhett

[1]: http://buildr.apache.org/testing.html#setup_teardown

> 
> I am an inexperienced ruby developer, so any direction is greatly
> appreciated.
> 
> Cheers


Mime
View raw message