I had to code something in Wicket (or take any MVC framework) that given 2 variables A and B provide the boolean result C which tells if something (a checkbox) is visible or not.
Now this is view logic, but let's say it is not as trivial as like: C = A && B; Maybe some automated testing is good to have.
Where would you put this logic? Is it okay to put it in the Model/Service layer and test it with JUnit ? In my understanding Model and Services are reserved for business logic.
Or do yo keep it in the View in which case you test it with something like Selenium ?
Or build some static method in some Utility package ?
I would build it as to get the thing done and build a test for it as simple as posible but not to mix it with the services. So i would chose a static utility method.
I use also complex visibility logic in one of my wicket MVC project, and I put this logic into the service layer, and I test this code with JUnit. I also have wickettester test which tests the visibility of the checkbox also. I don't know what the best way is, but think this way is not bad. Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With