Here are my main concerns in JUnit test logic inside activity class
using activities and places framework in GWT 2.3 and I am not sure if
this is been clearly addressed before or not.

Classic MVP Approach:
After reading tons of articles on stackoverflow and other blogs, I
understand that if you move the processing logic to a presenter class
and keep views as dumb as possible then we can test presenter class by
making our own custom views which implements HasText, HasClickHandlers
interfaces and inject that view in the presenter constructor and call
the presenter constructor from my JUnit test class. If I am using
classic MVP pattern I can test each presenter class using JUnit. Very
simple to do that.

Activities and Places Framework:
But when you designed the application with Activities and Places
framework it gets really tricky and I am having hard time
understanding how to do JUnit testing here. I haven't seen a good
example which shows a great JUnit testing of the logic inside Activity
with Activities and Places framework. With the Activities and Places
framework approach, really my activity class is now presenter +
activity. Which is fine but how to do JUnit on an activity class if my
logic goes inside activity class?

Here are my problems:

1) The constructor of activity requires Place and ClientFactory. I
really don't have to test place and client factory as it is a boiler
plate code which Google must have tested. I know that if
AppActivityMapper maps places with an activity it will call the
correct activity and it's start method. So if I have to test my logic
which is inside activity class I can't call Activity class unless I
fake out Place and ClientFactory classes in the constructor which is
annoying and I don't even know will faking out Place and ClientFactory
classes just to instantiate activity class will work.

2) If I have a private method which is called from the start() method
of the activity class (because I want to do some initial processing
when the activity starts) then I have to call Start() method from my
JUnit class which means I will have to pass AcceptsOneWidget &
EventBus. Why do I need to pass event bus in my JUnit testing when all
I am testing really is functionality inside activity class for that
view. How will I fake out AcceptsOneWidget & EventBus in JUnit? I
guess then I will have to use GWTTestCase which defeats the whole
purpose of moving code to avoid slow  GWTTestCase.

Please advise if anyone has a better understanding of creating JUnit
test cases with the activities and places framework.

PS: The only way I can think of right now is create your own presenter
class for each view class and don't make the activity as the
presenter. That way activity code will only instantiate new presenter,
new view and assign view to the presenter. Then I can JUnit presenter
class separately. But then in that acase what is the use of Activity
class really to begin with?





-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to