Ask HN: Web Dev Testing Best Practices
So I'm making the jump from a 150K employee company to being employee #18 at a web design agency. Part of my role, will be:
-Defining/Documenting how designs should work (aka setting up Requirements Managment)
-Process and Development definition(SDLC definition, refinement, deployment)
-Setting up and running QA (essentially, from what I know it's tested by the Dev team)
What I'd like to know, is how is everyone testing there webapps. Most things are built with Drupal or Sitecore (.NET).
24 comments
[ 38.7 ms ] story [ 559 ms ] threadIt's a bit of a pig to get used to initially, but I guarantee the first time you run a test and find a newly-introduced bug, it'll make your day - and your team's, for that matter.
Furthermore, Sauce Labs offer servers running lots of different OS/browser combinations that you can run your Selenium tests on.
In other words:
- we write our Selenium tests in Python (assert that when you click, X happens)
- they get run on our continuous integration server every time we push to GitHub
- the Selenium tests fire up IE 8 on Windows on a Sauce Labs server and run themselves
- the output gets piped back to us as part of our unit testing suite, emailing us if any of the tests fail
Well, we almost have it working as well as that :) Either way, we've been really impressed by Sauce Labs so far.
http://drupal.org/simpletest/
Core ships with a lot of tests and most of the larger contributed modules do too. They're pretty helpful to run frequently to make sure you haven't broken anything but they won't test your configuration or any of your front end stuff.
Here are two useful resources where you can learn more about these and successful automation approaches.
* The Secret Ninja Cucumber Scrolls (http://cuke4ninja.com/toc.html)
* Ideas for efficient BDD with SpecFlow through examples (http://ndcoslo.oktaset.com/t-4861) a very recent presentation, from NDC 2012, where the SpecFlow author goes through a couple of testing approaches.
Learn about the "Page Object" model approach to automated web testing. It's important for creating reusable, encapsulated tests that can evolve with the system under test. This is vital for advancing past the initial, small automated tests to much larger suites whilst still keeping them maintainable.
Here's a great start: http://jtaby.com/2012/04/23/modern-web-development-part-1.ht...
On the horizontal layers you have unit testing, integration testing, acceptance testing - which are tests at various levels of abstraction throughout your code base.
I then like to test the vertical slices tiers of the application - usually views, controllers, models, database etc. I like to see unit tests, integration tests, and 'acceptance tests' focusing in on each of those tiers to build confidence in the coverage of your testing.
Automation is absolutely key, and getting those automated tests into your continuous build and release process is definitely worthwhile.
1. Unit test both front and back end code. This thread is full of great examples for tools that will make that process easier.
2. Use a tool (I like jmeter) to frequently test how your project performs. You would be surprised how often small changes result in massive slowdowns, especially under load.
3. Bring basic usability testing into the QA fold. Web dev is extraordinarily client facing - projects live and die according to the whims of clients. Consequently, if you bring things like simple hallway testing into the development flow, your whole team will recognize how important it is to make things elegant and simple to use.
I try to write unit tests for internally developed libraries. For some projects, Selenium tests will be written as well.
And to answer your question: I am of course using it to test itself! Plus some selenium for basic automation, but without going overboard as the app is very javascript-heavy and interactive, which limits how much can be usefully/cost-effectively achieved with automation.
1 - Unit tests, low-level method testing w/ mocked or no external dependencies (such as db)
2 - Integration tests, test against external dependencies, such as db, apis
3 - System tests, front-end testing that covers all parts of the system using a tool such as Selenium
Terminology varies and differentiation of levels, as well, but this can serve as a good guideline.
You'll need to have everything automated and integrated into a build system where you can reliably kick off a build and see the results.
A note on Selenium: any non-trivial setup is going to require a fair number of resources, both in time and environments. Also, you will have to dedicate time to maintaining tests and your UI changes. However, the pay-off is quite large when you can run and end-to-end set of tests on your application and know that you didn't break something.
edit: formatting
It'll let you refresh changes on all your devices at once.
Unit tests of lower level back-end functionality is always a good idea, but I find it actually makes API development simpler because it frees you from the problems and complications inherent in testing via your target client.
Disclosure: I wrote the article.
As someone else said, it's basically account people clicking around, you fix stuff, they click more until they feel comfortable presenting it to the client. Then you find out that some bigwig at the client has a 5yr old blackberry where the layout doesn't work right, and that becomes your focus of your debugging for a week.
So from what I gather, eveyrone is a fan of selenium. I do recall it being brought up during my interviews.
Does anyone have a favorite resource they like? i.e: eBook, blog etc