You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frans Thamura <fr...@meruvian.org> on 2011/05/20 09:52:28 UTC

S2 TEst Best Practices

hi all

thx to john geppe that gave us a lot of example based on his jquery,
esp to change the cimande project with total jquery plugins

and i have several question, and i think that is good if we can share it here

i want to know, the test mechanisme , best practices of testing in Struts2 world

any reference

why, how,

esp i am here, using S2 and Spring, and now JSON very intensively

NB: i hope the jackson can be part of json plugins, and we find an
interesting implementation of using json plugins in real world

F

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


Re: S2 TEst Best Practices

Posted by Frans Thamura <fr...@meruvian.org>.
Will try so learn springstrutstestcase and jenkin

I just want the team have an automation that run automatic in best way

But manual also welcome
-----Original Message-----
From: Miguel <mi...@almeida.at>
Date: Fri, 20 May 2011 11:40:13 
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Re: S2 TEst Best Practices

On Fri, 2011-05-20 at 16:41 +0700, Frans Thamura wrote:

> my idea to setup jenkins/hudson server
> 
> so we can test it there
> 
> can TDD do this?
> 

TDD stands for test driven development. It is a development methodology.
The end result is (better and working) code and (more) tests. So of
course you can set that up in jenkins.

I am actually starting with jenkins and have little experience with CI
systems. Everything is easy until you have environment specific settings
(like different databases and database credentials, or upload paths).

Miguel Almeida


Re: S2 TEst Best Practices

Posted by Miguel <mi...@almeida.at>.
On Fri, 2011-05-20 at 16:41 +0700, Frans Thamura wrote:

> my idea to setup jenkins/hudson server
> 
> so we can test it there
> 
> can TDD do this?
> 

TDD stands for test driven development. It is a development methodology.
The end result is (better and working) code and (more) tests. So of
course you can set that up in jenkins.

I am actually starting with jenkins and have little experience with CI
systems. Everything is easy until you have environment specific settings
(like different databases and database credentials, or upload paths).

Miguel Almeida

Re: S2 TEst Best Practices

Posted by Frans Thamura <fr...@meruvian.org>.
my idea to setup jenkins/hudson server

so we can test it there

can TDD do this?

F



On Fri, May 20, 2011 at 4:38 PM, Miguel <mi...@almeida.at> wrote:
> Hi Frans,
> On Fri, 2011-05-20 at 14:52 +0700, Frans Thamura wrote:
>
>>
>> and i have several question, and i think that is good if we can share it here
>>
>> i want to know, the test mechanisme , best practices of testing in Struts2 world
>>
>
> I work in TDD, which means I write the tests first and then develop the
> functionality (check Lasse Koskela's book on the subject).
>
> My usual methodology is:
>
> - Pick up a story/use case (eg: click on People list button shows the
> list of all people in the phone book list)
> - Write a Test class for the PeopleAction.list() method
> - There will be a couple of tests: happy path, what if there aren't any
> people, what if there's a problem accessing the database?
> - Recently I've been developing a lot with services. this means the
> action will usually be simple, something like manipulate the properties
> that come from the request (if necessary) and pass them to the service
> - The last sentence means I can mock up the service here: I am
> interested in testing if the action behaves correctly - ie, if it
> catches exceptions, sends to the correct result, I am not really
> interested  in knowing if the database is being accessed correctly. So
> EasyMock is a good library to use
> - After building the test and the Action, I do have the problem: is my
> service (eg service.getAllPeople() ) working as expected? Time for some
> integration test. Bare in mind I'm working in TDD: I've build an
> interface for the service, but the implementation doesn't exist yet
> - I repeat the test-build cycle, this time to build the correct
> implementation of service.getAllPeople().
> - Work done
>
> Now, some remarks:
> - This unit testing doesn't do struts integration, such as:
>    - Struts validation
>    - My custom authorisation (I have developed a @AuthorisedRoles
> annotation that only authorised users with some roles to execute that
> action
>
> I'm not really sure what/when/where is the best way to test this. Right
> now I test this in a separate class that I suffix with, eg,
> *ValidationIntegrationTest. I'm not 100% happy with this approach, as
> a) I end up testing my action in 2 or 3 different places
> b) I'm not completely happy with my validation test class yet, which
> currently extends from StrutsSpringTestCase
>
>
> Regards,
>
> Miguel Almeida
>

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


Re: S2 TEst Best Practices

Posted by Miguel <mi...@almeida.at>.
Hi Frans,
On Fri, 2011-05-20 at 14:52 +0700, Frans Thamura wrote:

> 
> and i have several question, and i think that is good if we can share it here
> 
> i want to know, the test mechanisme , best practices of testing in Struts2 world
> 

I work in TDD, which means I write the tests first and then develop the
functionality (check Lasse Koskela's book on the subject).

My usual methodology is:

- Pick up a story/use case (eg: click on People list button shows the
list of all people in the phone book list)
- Write a Test class for the PeopleAction.list() method
- There will be a couple of tests: happy path, what if there aren't any
people, what if there's a problem accessing the database?
- Recently I've been developing a lot with services. this means the
action will usually be simple, something like manipulate the properties
that come from the request (if necessary) and pass them to the service
- The last sentence means I can mock up the service here: I am
interested in testing if the action behaves correctly - ie, if it
catches exceptions, sends to the correct result, I am not really
interested  in knowing if the database is being accessed correctly. So
EasyMock is a good library to use
- After building the test and the Action, I do have the problem: is my
service (eg service.getAllPeople() ) working as expected? Time for some
integration test. Bare in mind I'm working in TDD: I've build an
interface for the service, but the implementation doesn't exist yet
- I repeat the test-build cycle, this time to build the correct
implementation of service.getAllPeople(). 
- Work done

Now, some remarks:
- This unit testing doesn't do struts integration, such as:
    - Struts validation
    - My custom authorisation (I have developed a @AuthorisedRoles
annotation that only authorised users with some roles to execute that
action

I'm not really sure what/when/where is the best way to test this. Right
now I test this in a separate class that I suffix with, eg,
*ValidationIntegrationTest. I'm not 100% happy with this approach, as
a) I end up testing my action in 2 or 3 different places
b) I'm not completely happy with my validation test class yet, which
currently extends from StrutsSpringTestCase


Regards,

Miguel Almeida

RE: S2 TEst Best Practices

Posted by Miguel <mi...@almeida.at>.
On Fri, 2011-05-20 at 09:29 -0400, Dave Newton wrote:

> On May 20, 2011 9:26 AM, "Ilya Kazakevich" wrote:
> > There should not be logic in view. If there is no logic -- there is
> nothing
> > to test:)
> 
> Sure there is, and I'm not even including JavaScript-based functionality.
> Are the right things displayed? Does the UI reflect proper state? Is the
> flow correct? Etc.
> 

I'm with Dave on this one. It's curious, because as we speak I am
thinking how to test authorisation. My authorisation is based on 2
things:

1 - @Roles("role1,role2") annotation on the method/class

This is easily tested with, eg, java reflection that compares the roles
with an expected list of roles (you can ever automate it so that you
fetch the list of all authorisations from a file and test all mehtods in
the same test class

2 - <customtag:roles allowed="somerole"> content </customtag:roles>,
which gets displayed or not depending on what roles the user has.

Like Dave points out, this falls into the category of "Are the right
things displayed". 

RE: S2 TEst Best Practices

Posted by Dave Newton <da...@gmail.com>.
On May 20, 2011 9:40 AM, "Ilya Kazakevich" wrote:
> That is action logic, not view itself.

Sure, unless there's a bug in the view layer, which is why it gets tested.

Dave

RE: S2 TEst Best Practices

Posted by Ilya Kazakevich <Il...@JetBrains.com>.
That is action logic, not view itself.


//Action (could be tested):
void execute() {
   if (someCondition) {showSomething = true;}
}


//jspx:
<c:if="${action.showSomething}">${action.something}</c:if>


 


Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
"Develop with pleasure!"

-----Original Message-----
From: Dave Newton [mailto:davelnewton@gmail.com] 
Sent: Friday, May 20, 2011 5:29 PM
To: Struts Users Mailing List
Subject: RE: S2 TEst Best Practices

On May 20, 2011 9:26 AM, "Ilya Kazakevich" wrote:
> There should not be logic in view. If there is no logic -- there is
nothing
> to test:)

Sure there is, and I'm not even including JavaScript-based functionality.
Are the right things displayed? Does the UI reflect proper state? Is the
flow correct? Etc.

Dave


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


RE: S2 TEst Best Practices

Posted by Dave Newton <da...@gmail.com>.
On May 20, 2011 9:26 AM, "Ilya Kazakevich" wrote:
> There should not be logic in view. If there is no logic -- there is
nothing
> to test:)

Sure there is, and I'm not even including JavaScript-based functionality.
Are the right things displayed? Does the UI reflect proper state? Is the
flow correct? Etc.

Dave

Re: S2 TEst Best Practices

Posted by Frans Thamura <fr...@meruvian.org>.
We move all our struts2 app to all json

We extend current json plugins

And we play around with interceptor

We want to test this 

So,

Our apps is json server based on s2

Dunno

Is this best

Still seeking a way to test

Fyi the return still http post
-----Original Message-----
From: "Ilya Kazakevich" <Il...@JetBrains.com>
Date: Fri, 20 May 2011 17:25:46 
To: 'Struts Users Mailing List'<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: RE: S2 TEst Best Practices

Upper level functional tests. But it is not a really good idea.

I believe view layer (templates) should be as simple as possible. All view
logic should be implemented in presenters (actions in struts). They are java
classes with out of HTTP or HTML dependencies and could be tested.
 
Action tells to view (written in jsp for example): "display user name" or
"hide cancel button".

There should not be logic in view. If there is no logic -- there is nothing
to test:)


Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
"Develop with pleasure!"

-----Original Message-----
From: Miguel [mailto:miguel@almeida.at] 
Sent: Friday, May 20, 2011 5:18 PM
To: Struts Users Mailing List
Subject: RE: S2 TEst Best Practices

On Fri, 2011-05-20 at 15:38 +0400, Ilya Kazakevich wrote:

> Hello,
> 
> In pure struts your action is just a presenter (see MVP pattern). So you
can
> test it using unit testing engines like testNG and jUnit.
> 
> For GUI testing you can use selenium.

Ilya, what kind of tests do you usually run with selenium? 

An interesting view on this from Gojko Adzic seems to almost suggest
these tests should be avoided: see in
http://gojko.net/2010/04/13/how-to-implement-ui-testing-without-shooting-you
rself-in-the-foot-2/




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


RE: S2 TEst Best Practices

Posted by Ilya Kazakevich <Il...@JetBrains.com>.
Upper level functional tests. But it is not a really good idea.

I believe view layer (templates) should be as simple as possible. All view
logic should be implemented in presenters (actions in struts). They are java
classes with out of HTTP or HTML dependencies and could be tested.
 
Action tells to view (written in jsp for example): "display user name" or
"hide cancel button".

There should not be logic in view. If there is no logic -- there is nothing
to test:)


Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
"Develop with pleasure!"

-----Original Message-----
From: Miguel [mailto:miguel@almeida.at] 
Sent: Friday, May 20, 2011 5:18 PM
To: Struts Users Mailing List
Subject: RE: S2 TEst Best Practices

On Fri, 2011-05-20 at 15:38 +0400, Ilya Kazakevich wrote:

> Hello,
> 
> In pure struts your action is just a presenter (see MVP pattern). So you
can
> test it using unit testing engines like testNG and jUnit.
> 
> For GUI testing you can use selenium.

Ilya, what kind of tests do you usually run with selenium? 

An interesting view on this from Gojko Adzic seems to almost suggest
these tests should be avoided: see in
http://gojko.net/2010/04/13/how-to-implement-ui-testing-without-shooting-you
rself-in-the-foot-2/




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


[OT] RE: S2 TEst Best Practices

Posted by Dave Newton <da...@gmail.com>.
On May 20, 2011 9:18 AM, "Miguel" wrote:
> An interesting view on this from Gojko Adzic seems to almost suggest
> these tests should be avoided:

I read it more as "do them right".

Dave

RE: S2 TEst Best Practices

Posted by Miguel <mi...@almeida.at>.
On Fri, 2011-05-20 at 15:38 +0400, Ilya Kazakevich wrote:

> Hello,
> 
> In pure struts your action is just a presenter (see MVP pattern). So you can
> test it using unit testing engines like testNG and jUnit.
> 
> For GUI testing you can use selenium.

Ilya, what kind of tests do you usually run with selenium? 

An interesting view on this from Gojko Adzic seems to almost suggest
these tests should be avoided: see in
http://gojko.net/2010/04/13/how-to-implement-ui-testing-without-shooting-yourself-in-the-foot-2/



RE: S2 TEst Best Practices

Posted by Ilya Kazakevich <Il...@JetBrains.com>.
Hello,

In pure struts your action is just a presenter (see MVP pattern). So you can
test it using unit testing engines like testNG and jUnit.

For GUI testing you can use selenium.
 

Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
"Develop with pleasure!"

-----Original Message-----
From: Frans Thamura [mailto:frans@meruvian.org] 
Sent: Friday, May 20, 2011 11:52 AM
To: Struts Users Mailing List
Subject: S2 TEst Best Practices

hi all

thx to john geppe that gave us a lot of example based on his jquery,
esp to change the cimande project with total jquery plugins

and i have several question, and i think that is good if we can share it
here

i want to know, the test mechanisme , best practices of testing in Struts2
world

any reference

why, how,

esp i am here, using S2 and Spring, and now JSON very intensively

NB: i hope the jackson can be part of json plugins, and we find an
interesting implementation of using json plugins in real world

F

---------------------------------------------------------------------
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