vert-x / testtools

Vert.x 2.x is deprecated - use instead
http://vertx.io/docs/vertx-unit/java/
Other
10 stars 10 forks source link

Declarative verticle and module deployment #14

Open RichardWarburton opened 11 years ago

RichardWarburton commented 11 years ago

The old test annotations project had a way of declaring which verticles and modules you wanted to have deployed, ie what your test depended upon, before a test was run. This has been removed in testtools in favour of manual deployment.

The freedom given by manual deployment is good, but it would be helpful if there was some support for declaring things you want to deploy. This could come in the form of an annotation or it could come in the form of a method, for example:

public List<Deployable> getModulesToDeploy() {
    return Arrays.asList(new Deployable("io.vertx~mod-mongo-persistor~2.0.0-beta1", "config.testdb.json"));
}

At the moment when using testtools we're finding we do this a lot. Its a requirement that verticles are brought up and deployed before tests start executing.

purplefox commented 11 years ago

In the old framework it the actually Junit test and the test verticle where different things which meant you had to maintain at least two classes for each test.

In the new framework the test IS the verticle so declaring the verticle that actually gets deployed in an annotation is redundant.

RichardWarburton commented 11 years ago

Here's a motivating scenario. I've got some code which tests a verticle called Foo. Foo talks to the mongo persistor which is a module. So before I run any tests on Foo i need to deploy mod-mongo-persistor and wait for it to come up, using the completion handler before I run the test. I don't want to put code in every test I write in order to download the module - I'd simply like to declare that I need a module to be loaded.

purplefox commented 11 years ago

Oh I see, you don't need to put the code that deploys mongopersistor in each test - you could add this in the start() method of the test verticle and it ill be executed for each test.

RichardWarburton commented 11 years ago

Thanks Tim, but that's what I'm doing already as a workaround. The issue is that if you want to have more than one modules or dependent verticles to deploy then the code gets quite nasty quite rapidly and it feels like the kind of concern that the testing framework should take care of for me.

If you're happy to accept this as an issue then I don't mind looking into writing a fix.

purplefox commented 11 years ago

Right, I can see that what you suggest could be useful. Sure please go ahead and implement it if you like :)

rhoegg commented 9 years ago

This issue is pretty old, but looks valuable to me.