-
1. Re: Weld, TDD and Weld Test
gavin.king Jan 11, 2010 3:53 PM (in response to stormtag)You don't need any special framework to unit test your CDI beans! Or do you mean integration testing?
-
2. Re: Weld, TDD and Weld Test
stormtag Jan 11, 2010 5:23 PM (in response to stormtag)googles the difference I guess?
If a given function on a service invokes another service, and that service needs to be injected, is that a unit test or an integration test?
-
3. Re: Weld, TDD and Weld Test
gavin.king Jan 11, 2010 5:52 PM (in response to stormtag)By the strictest definition of
unit test
, a unit test is a test of the unit, i.e. the class, in isolation. Now, I don't think that this kind of test is very useful at all (since it doesn't test anything about the true system requirements), and even worse it makes the code more difficult to refactor (since you have to change your tests for minor refactoring tasks).However, in practice, I think a lot of people write unit tests that actually test the interactions between several classes, and in this case, yes,
services
need to be injected. But they don't need to be injected by CDI. You can inject them by calling the constructor or initializer method yourself.I don't think
unit test
is a good word to use for tests which involve the container. I call theseintegration tests
, though that term may also be incorrect. For this kind of test, the Weld Java SE extension will probably get you quite far, but yes, we are working on something better.(Yes, I know a lot of people use
unit test
to refer to any kind of automated test, but I think this is a very confusing usage.) -
4. Re: Weld, TDD and Weld Test
stormtag Jan 11, 2010 9:44 PM (in response to stormtag)
For this kind of test, the Weld Java SE extension will probably get you quite far, but yes, we are working on something better.Cool. I found this while googling on how to implement this but I'm not sure what CDIRunner would do and the link seems to be broken.
-
5. Re: Weld, TDD and Weld Test
peteroyle.howardmoon.hitcity.com.au Jan 12, 2010 11:14 AM (in response to stormtag)If you'd like to try the pure Weld SE approach, here's an example TestNG test for reference.