So You Want to Run Tests in Parallel... Now What??
Sauce AI for Test Authoring: Move from intention to executing in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intention to executing in minutes.
|
x
This is a guest blog post by Sarah Goff-Dupont, Product Marketing Manager forAtlassian Bamboo.
Fast feedback on code change has be a bit of an compulsion e'er since the Agile2012 league got me thinking about how important this is for agile squad in special -- partly because turbo-charged feedback is a natural work-in-progress clipper. How so? Getting results backward to devs so promptly that they don & # x27; t have time to commence in on another issue keeps everyone focused on the task at hand. That, in turn, fosters an efficient development process. And efficiency, in my never-humble opinion, is what agile development is all about.

Running automated trial in analogue is a great way to reduce build times and get results to developers and QA technologist faster. Today I & # x27; m going to dig rearwards into my long-lost career as a test automation engineer and share with you the technique we used for running tests in parallel. & # x27; Cuz it was super-slick and I loved it. I & # x27; ll useAtlassian Bamboo(which mix nicely with, btw) as my example CI tool as we walk through it.
TestNG Groups FTW!
If you & # x27; ve never used TestNG before, you might think that & # x27; s a typo above and that I meant & quot; TestING & quot;. (Google & # x27; s autocomplete certainly thinks it & # x27; s a erratum, so hey: you & # x27; re in full company.) But no. TestNG is an automated examination utility, much like JUnit. In fact, you can use it in combination with JUnit, WebDriver, Selenium, etc. And the reason you & # x27; d want to is Groups. By sieve your test suite into radical, then creating separateJobsin Bamboo to run each group, you can speed up your testing degree by 100 % -- and potential, good. TestNG is design for Java tests, but can also be expend for Ruby projects. And it & # x27; s not the only fabric to volunteer groups. Proboscis for Python and PHPUnit also receive them. JUnit has & quot; class & quot;, which largely serve the same intention, but are rather clunky and make TestNG & # x27; s groups seem like a bacon-wrapped Ferrari by comparison (sleek, fast, and yummy).

Implementing Groups in Your Test Code
Like a handful of other testing model, TestNG direct it & # x27; s cues from an @ Test annotation. Inside that, you can position a bit of dimension, one of which is Groups. Group names are both dynamic and arbitrary -- little sentence, big implications. First, you can make a new group on the fly but by assigning a test to it. No want to announce and define the group in a separate file. The act of delegate a test to a group will also create that group, if it doesn & # x27; t already exist. (Now, that & # x27; s a double-edged blade because it also means you can end up with a group called & quot; smoke_test & quot; and another called & quot; smoke_tets & quot; if you & # x27; re careless.) Second, you can devise whatever system (or systems) of meaning you like for your radical. Slice them along functional country of the application, by level of the codification stack, by whether you currently expect the test to legislate, etc. And examination can belong to multiple groups. So a single test might conceivably belong to the & quot; user_authentication & quot;, & quot; API & quot;, & quot; smoke_test & quot; and & quot; in_development & quot; groups. TestNG even support radical of groups. I haven & # x27; t play with that personally, but it & # x27; s middling bad-ass and theirdocumentationon it is helpful.
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

Of trend, if your covering & # x27; s super-structure doesn & # x27; t cognise about TestNG, you & # x27; ll get all sort of errors and your builder won & # x27; t know what do with all those groups at runtime. So be sure to announce TestNG as a dependance for your project or module.
Using Groups in Bamboo Builds
Back in Bamboo, set up Jobs based on the groups you & # x27; ve defined in your test code. If you & # x27; re executing tests via Maven, Gradle or Ant, this is pretty lilliputian. In the example present hither, I pass a group name into Maven as an argument. When it & # x27; s clip to run the tests, TestNG will scrub my undertaking, pull out all the tests belonging to that radical, and run only those. Doesn & # x27; t matter if the tests for that group are located in different classes or package. As long as they & # x27; re in the same project or module, TestNG will notice them.

Note that because each Job has it & # x27; s own working build directory, you & # x27; ll need to pull the test code into each Job. A source code checkoutTaskis broadly the simplest way to do that. If your codification groundwork is declamatory, you can take advantage of the option to check out from a sub-directory in your repo and only pull down that part of the tree. Another option is pulling down all the trial codification in the very maiden Stage of your Plan, so zip it up and passing that as an artefact to downstream Jobs.
Agents of Change
It & # x27; s believably obvious, but break your tryout suite into 10 spate isn & # x27; t going to help you much if you merely have 1 or 2build agent. Of course we & # x27; d enjoy if everyone bought a Bamboo license that supports lots of agent so they can really take advantage of parallelization. Maybe that & # x27; s feasible for you, and maybe not. Either way, be mindful of your agent tally when considering how to split up your test suite so you & # x27; re not just spinning your wheels. You can take this idea of parallelized tests about as far as you want. There & # x27; s no restriction as far as TestNG or Bamboo is concerned. Many of our own CI builds have over 20 test groups running simultaneously. Again: you & # x27; re determine only by the act of build agent you & # x27; re running.

A Parallel Universe
As with most thing in build engineering, there are various ways to accomplish parallelized testing. Tinkering with custom scripts or your suite.xml are two other common approaches. For big multi-module projects, it might make sense to split the suites/groups into separate repositories and run a Job for each repo. Regardless of which method you choose, you & # x27; ll get the well-nigh bang for your buck by pore your parallelization efforts on integration-, API- and UI-level examination. Unit-level tests already run rather fast, so they & # x27; re improbable to be the constriction in your builds. (Extra credit for the over-achievers: many testing frameworks allow you to run unit tests multi-threaded!) If you & # x27; re new to test parallelization, congratulations on do it all the way through this blog! Check out our newautomated testing imagination pagefor more helpful tips & amp; tricks.
----- Sarah Goff-Dupontis a former test mechanisation technologist, and a fan of anything that create life easier for the swot. Like Uninterrupted Integration and automation, for example. Because manual try gets boring. Her heros include Margret Thatcher, MacGyver, and her mom.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free