-
1. Re: Need some explanation of which dependencies need to be added to a deployment
kpiwko Nov 25, 2013 4:34 AM (in response to martin.ahrer)Hey Martin,
there are basically two different things:
Microdeployments define only what is really needed to run the test. The point is they are small and thus quickly deployable. You can think of testing a EJB, for instance, you need only to deploy interface and its implementation. Microdeployments are basically core for unit testing. Microdeployments are usually tested in container = the test runs in the JVM of application server inside of the application, which is default behavior.
Full deployments define the application as you would deploy it. There are used mainly for functional testing, where you need to package your application the same way as you would do manually. Full deployments are usually tested in as client mode, defined by @Deployment(testable=false) or by @RunAsClient annotation. Client mode means that server with app is different JVM than test itself. So REST and Selenium are the most logical testing means here.
So, the point is to figure out what you exactly need. There are the bits you should take in mind:
- if the classes you want to deploy depend on libraries, you need to add those libraries into deployment unless they are provided by application server. That's the reason why Servlet 3.0 works fine and Spring is not. See ShrinkWrap Resolvers how to do that https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc
- if you want to test UI, you likely need to deploy content of src/main/webapp. You can use ShrinkWrap Resolver MavenImporter, ShrinkWrap ZipImporter or ExplodedImporter or an utility that recursively traverse that directory.
- If you are running in Server, make sure that you deploy all the classes referenced by test class as well. For instance Apache Commons or such. They won't be available on server after deployment. (Note: Arquillian autoadds testing - junit, hamcrest, etc)
HTH,
Karel
-
2. Re: Need some explanation of which dependencies need to be added to a deployment
martin.ahrer Nov 25, 2013 2:39 PM (in response to kpiwko)Hi Karel,
thanks for your explanation. But I fear I have not expressed my problem clear enough. My server side implementation consists of about 5 classes that make up my REST service (+ a ton of 3rd party libraries which are setup as dependencies in my IDE/gradle build).
However, for my test I didn't add any of these classes nor did I add any of the 3rd-party libraries (as you see in my test code above) to the deployment. I only added the Servlet 3.0 Initializer but still when invoking the test (in IDE or from gradle command line) the test goes green.
I'd expect ClassNotFoundExceptions etc. as I haven't really done my micro deployment. But in fact the REST service implementation finds all dependencies (classes+libraries) in its classpath.
Thanks
Martin