Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Effective Unit Testing: Presentation Layer

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ) 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...
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic