struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Struts 2 Testing Actions
Date Thu, 28 Nov 2013 06:27:33 GMT
Yes, use mocks -> Mockito


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/11/28 Damian Blazejewski <damian.blazejewski@gmail.com>:
> I don't want to extend StrutsSpringJUnit4TestCase as it enforces me to
> provide all Spring dependencies required by the action itself.
> Although the Struts Action I want to test is dependent only on two Spring
> beans, those beans have a lot of other dependencies and so on.
> What I would like to do is mocking all Struts Action dependencies and then
> doing some tests.
> Is it possible to do it that way?
>
>
> Pozdrawiam/Best regards,
> Damian Błażejewski
> dblazejewski.com
>
>
> 2013/11/27 Lukasz Lenart <lukaszlenart@apache.org>
>
>> 2013/11/26 Damian Blazejewski <damian.blazejewski@gmail.com>:
>> > I have managed to sort it out. My project has two maven modules and one
>> > parent pom common for those modules.
>> > Tests are located in on of the submodules.
>> > As turns out, when I add servlet-api and jsp-api dependencies to the
>> parent
>> > pom, the error is present.
>> > However, when I move those two dependencies to the module's pom which
>> tests
>> > are located in, error disappears.
>> > So that problem is solved.
>> > Unfortunately, there is another issue. I have almost given up but my
>> desire
>> > to start automatically testing Struts actions is stronger so I still
>> > struggle :)
>> > I have Spring dependencies in the actions itself. It would be perfect if
>> I
>> > could mock them. But as far as I know I can't but I should provide spring
>> > application context
>> > defining those dependencies.
>> >
>> > When I try to extend StrutsJUnit4TestCase in my test I get the following
>> > error:
>> >
>> > "Looks like the Spring listener was not configured for your web app! "
>> >
>> > When I extend StrutsSpringJUnit4TestCase, I have to provide Spring
>> > dependencies as I said earlier.
>> >
>> > Is there any way to mock those Spring dependencies in my Struts action?
>>
>> I'm not sure if I understand you - why don't you use
>> StrutsSpringJUnit4TestCase?
>>
>>
>> http://struts.apache.org/release/2.3.x/docs/struts-2-junit-plugin-tutorial.html
>> http://struts.apache.org/release/2.3.x/docs/testing-actions.html
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message