This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Effective Unit Testing: Presentation Layer

 
Erron Austin
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen a lot of UI frameworks starting to push unit testing down to the UI layer.

Do you have recommendations about how best to unit test UI code, e.g. GWT, Vaadin, Javascript frameworks?
In our opinion, does testing the UI logic make sense for this layer or should you focus on E2E testing with tools like Selenium?

Thanks,
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I would do depends so much on the actual code base and technologies involved that it's quite difficult to say much in that direction. With that said, and generalizing a bit, I would expect to see some kind of a "pyramid" shape in place where most of the volume would be in low level, isolated unit tests for individual objects or small clusters of objects and the closer to the system's boundaries your tests would get the fewer and fewer of such tests you would have.

For instance, I'd expect a JavaScript-heavy code base to have unit tests for individual "objects" or functions and I'd expect to have a handful of end-to-end tests with Selenium and the like for increasing the team's certainty about not having broken anything in the larger scheme of things. I would most certainly not want to run thousands of Selenium tests to cover all possible combinations of user input on a form checking that the client-side validations work correctly. Instead, I'd like to check that validations in general for that form are invoked and the UI reflects their result.

I don't know much at all about Vaadin (even though it's built by a bunch of Finns – we're not that small a country :wink and I've only been exposed to GWT on one project shortly. It does seem, however, that most web frameworks aren't really all that test-friendly. They might go really far in making integration testing straightforward but at the same time they might make it really difficult to isolate individual objects for unit testing.

There's a guy in Norway called Johannes Brodwall who's been promoting raw Servlets the past couple of years. It may sound like going back to the stone age but he's got a point – web frameworks can very easily become like an octopus that spreads its tentacles throughout your code base. Anyway, I sense that this is going towards an unnecessary (and somewhat off-topic) rant so I'll just stop here...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic