Today i want to help you manage your Automated GUI Tests (Selenium) better. In the past i have seen many different ways people handle this. Some people just write those plain HTML TestCases with Selenium-IDE, store it somewhere on the HDD and run manually when needed. Others dont even use Selenium-IDE. They write pure Java for Example, and automate their execution with JUnit. My todays solution lies inbetween.
Precondition
I want plain HTML TestCases, created with Selenium-IDE. So that someone with little Programming skills can still create them.
I want these GUI Tests to be run automatically in my Build process, so my CI-Tool can notify me on errors.
I also want all TestCases under Versioncontrol in my Projects Repository since the Tests grow with the Source.
I want the most little effort with the highest outcome. So i dont want to export JUnit Tests out of my HTML TestCases since it would be kind of a Duplication - and i want to stick to the DRY Principle.
Solution
First of all i create a Folder in my Project for the Selenium-Tests.
So i have my TestSuite in Place. But how do i run them? Most importantly, it should run within the Maven Build Process, so it will also run on Jenkins-CI or whatever. As we are Testing against a real running WebApp this is an IntegrationTest per definition. In Maven we have the opportunity to run such Tests within the integration-test Phase. If you want to learn more about the Maven Build Life-cycle and its phases check out this. So we need some kind of WebServer to run our WebApp, otherwise the tests wont work. The WebServer should be started before the integration-test Phase, and be stopped afterwards. We could Use Tomcat7 or Jetty for example. In this example i will use the tomcat7-maven-plugin. I configure my pom.xml to start Tomcat7 pre-integration-test.
Now, whenever we execute mvn clean verify or even mvn clean install in console, the Tests are run and reports are stored within the target directory. This will also be done by your CI-Tool.
Conclusion
We do have a complete and clean Setup.
We have a place to store our Tests,
They are within the Sourcecode and Version control
They can be run automatically by CI-Tools
Even Non-developers can add new TestCases
Btw: Dont give up if something is not working as intended. Selenium seems a little buggy, and some times you have to dig a little to solve problems. But it really works, i figured it out. I hope you enjoyed this Guide. Greetings.
This is a quick one already discussed during my recent workshop in Warsaw, a concept rarely considered or adopted from JS developers. What Are Polyfills If we are updated enough to know ECMAScript 5th Edition, we probably know all possible shims and fallbacks for Array extras as well (e.g. Array.prototype.forEach ). Polyfills are simply snippets able to bring features already available for most recent browsers into those not updated yet. Why Polyfills If we develop with present and future in mind, we can take advantage of most recent techniques and solutions in order to both speed up via native support, where available, and maintain our application just stripping out code once all target browsers support them natively ... isn't this cool ?! Polyfills Side Effects The most common side effect of a polyfill is performances impact . The Array::forEach is already a good example of decreased performances. If we think about a forEach, it's nothing different than a classic for loop , e...
There are way too many ways to stub functions or methods, but at the end of the day all we want to know is always the same: has that function been invoked ? has that function received the expected context ? which argument has been passed to that function ? what was the output of the function ? Update thanks to @bga_ hint about the output property in after notification, it made perfect sense The Concept For fun and no profit I have created a prototype which aim is to bring a DOM like interface to any sort of function or method in order to monitor its lifecycle: the "before" event, able to preventDefault() and avoid the original function call at all the "after" event, in order to understand if the function did those expected changes to the environment or to a generic input object, or simply to analyze the output of the previous call the "error" event, in case we want to be notified if something went wrong during function execution the "handlerer...
Something " truly dangerous " to play with: a proxy file able to understand everything via XMLHttpRequest, enabling any sort of cross site requests (no COMET yet, it could arrive soon). Dunno even why I am posting this " little monster ", but I am sure a lot of people would like to have " access to the entire web " simply using Ajax, and nothing else, something like this: function website_exists(url){ var xhr = new XMLHttpRequest; xhr.open("HEAD", "proxy.php?url=" + (url), false); xhr.send(null); return 199 }; if(website_exists("http://gogle.com")) alert("Of Course, It's Big G!"); WebReflection PHP Proxy <?php /** XMLHttpRequest PHP Proxy * @author Andrea Giammarchi * @blog http://webreflection.blogspot.com/ * @license Mit Style License * @requires curl and Apache webserver * @description basic authentication, GET, POST, HEAD, PUT, DELETE, others ...
Comments
Post a Comment