/Xavier



On Aug 23, 2012, at 9:48 AM, Max Rydahl Andersen wrote:

As I read idea #4 (diagram), I wonder if it would be possible to have some Arquillian tooling based on the CDI context to generate something like this:

package org.arquillian.example;



import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.runner.RunWith;



@RunWith(Arquillian.class)
public class BasketTest {


@Deployment


public static JavaArchive createDeployment() {


return ShrinkWrap.create(JavaArchive.class, "test.jar")


.addClasses(Basket.class, OrderRepository.class, SingletonOrderRepository.class)


.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");


}
}
The idea would be that from a custom Arquillian Test wizard, you could specifiy with Bean is to be tested, and then generate the proper test skeleton, including the 'createDeployment()' method.

Something like https://issues.jboss.org/browse/JBIDE-8553 ?
yes, indeed.


Also, some validation tooling could report problems if other required beans (that are injected in the one to be tested) are not declared in the archive.
I understand that it does not cover all use cases, especially when m2 dependencies should be included in the test archive, but it could be a starting point..

Sounds good, but not sure if this last one is technical feasible since you would actually need to *execute* the @deployment method to validate it....aka. run the test.

well, the tooling could look at the import declarations of the beans, locate the imported types and include the proper classes/jars in the archive.  

thoughts ?

/max