{"id":468,"date":"2012-08-14T10:47:37","date_gmt":"2012-08-14T08:47:37","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=468"},"modified":"2012-08-14T10:47:37","modified_gmt":"2012-08-14T08:47:37","slug":"migrating-my-mind-to-maven-part-7-functional-testing","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=468","title":{"rendered":"Migrating my Mind to Maven (Part 7) \u2013 Functional Testing"},"content":{"rendered":"<p>Functional testing with <a href=\"http:\/\/wiki.netbeans.org\/JellyTools\">JellyTools<\/a> is fairly unfamiliar territory for me, so this morning I decided to spend some time to learn how it works with a Maven-based NetBeans Platform Application. JellyTools is a library based on <a href=\"http:\/\/jemmy.java.net\/\">Jemmy<\/a>, which allows you to manipulate GUI components during automated functional testing.<\/p>\n<p>My first attempt at following the <a href=\"http:\/\/wiki.netbeans.org\/Writing_JellyTools_Tests_Guide\">Writing JellyTools Tests Guide<\/a> <em>almost<\/em> succeeded. I created a JUnit test in one of my modules and modified it according to the guide. I also added a test dependency on org.netbeans.api:org-netbeans-modules-jellytools-platform. The test compiled and was executed as expected, but the error message returned by the test was that the class org.netbeans.Main was not found. <\/p>\n<p>So I decided to try moving it to the application module. And that did the trick!<\/p>\n<p>Now I have the following test class in my application module:<\/p>\n<p>[java]import java.util.logging.Level;<br \/>\nimport junit.framework.Test;<br \/>\nimport org.netbeans.jellytools.JellyTestCase;<br \/>\nimport org.netbeans.jellytools.TopComponentOperator;<br \/>\nimport org.netbeans.jemmy.operators.JButtonOperator;<br \/>\nimport org.netbeans.junit.NbModuleSuite;<\/p>\n<p>public class FirstScreenTest extends JellyTestCase {<\/p>\n<p>    private JButtonOperator _btn;<br \/>\n    private TopComponentOperator _tc;<\/p>\n<p>    public FirstScreenTest(String name) {<br \/>\n        super(name);<br \/>\n    }<\/p>\n<p>    public static Test suite() {<br \/>\n        NbModuleSuite.Configuration conf =<br \/>\n                NbModuleSuite.createConfiguration(FirstScreenTest.class).<br \/>\n                clusters(&#8220;.*&#8221;).<br \/>\n                enableModules(&#8220;.*&#8221;).<br \/>\n                failOnException(Level.INFO).<br \/>\n                failOnMessage(Level.SEVERE);<br \/>\n        conf = conf.addTest(&#8220;clickButtonTest&#8221;);<br \/>\n        return NbModuleSuite.create(conf);<br \/>\n    }<\/p>\n<p>    public void clickButtonTest() {<br \/>\n        System.out.println(&#8220;test case: click button&#8221;);<br \/>\n        _tc = new TopComponentOperator(&#8220;TC&#8221;);<br \/>\n        _btn = new JButtonOperator(_tc, &#8220;Button&#8221;);<br \/>\n        _btn.push();<br \/>\n    }<br \/>\n}[\/java]<\/p>\n<p>When I test the application (right-click on the application project and choose Test), the GUI is started up and the first button on the first screen is successfully pushed by the testing framework. \ud83d\ude42<\/p>\n<p><strong>Useful Links<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/wiki.netbeans.org\/JellyTools\">JellyTools wiki page<\/a><\/li>\n<li><a href=\"http:\/\/wiki.netbeans.org\/Writing_JellyTools_Tests_Guide\">Writing JellyTools Tests Guide<\/a><\/li>\n<li><a href=\"http:\/\/wiki.netbeans.org\/Writing_JellyTools_Operators_Guide\">Writing JellyTools Operators Guide<\/a><\/li>\n<li><a href=\"http:\/\/wiki.netbeans.org\/Jemmy_Samples\">Jemmy Samples<\/a><\/li>\n<li><a href=\"http:\/\/bits.netbeans.org\/dev\/javadoc\/org-netbeans-modules-jellytools-platform\/\">JellyTools API documentation (javadocs)<\/a><\/li>\n<\/ul>\n<p>And only after writing this I also found the useful pages below. Where were they hiding earlier? \ud83d\ude42<\/p>\n<ul>\n<li><a href=\"http:\/\/netbeans.dzone.com\/nb-mvn-functional-tests\">Functional Tests in a Maven-Based NetBeans Platform Application<\/a><\/li>\n<li><a href=\"http:\/\/platform.netbeans.org\/tutorials\/nbm-test.html#functional\">NetBeans Platform Test Infrastructure Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/wiki.netbeans.org\/Jemmy_Tutorial\">Jemmy Tutorial<\/a><\/li>\n<\/ul>\n<p>And here are some resources on running these tests as part of a Jenkins build.<\/p>\n<ul>\n<li><a href=\"http:\/\/blog.dahanne.net\/2011\/07\/18\/run-ui-tests-on-a-headless-jenkins-hudson-continuous-integration-server-running-ubuntu\/\">Run UI tests on a headless Jenkins \/ Hudson Continuous Integration server running Ubuntu<\/a><\/li>\n<li><a href=\"http:\/\/forgetfulprogrammer.wordpress.com\/2011\/09\/21\/netbeans-gui-tests-on-jenkins-windows\/\">NetBeans GUI tests on Jenkins + Windows<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Functional testing with JellyTools is fairly unfamiliar territory for me, so this morning I decided to spend some time to learn how it works with a Maven-based NetBeans Platform Application. JellyTools is a library based on Jemmy, which allows you to manipulate GUI components during automated functional testing. My first attempt at following the Writing &#8230; <a title=\"Migrating my Mind to Maven (Part 7) \u2013 Functional Testing\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=468\" aria-label=\"More on Migrating my Mind to Maven (Part 7) \u2013 Functional Testing\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[2,3,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-7y","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/468"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=468"}],"version-history":[{"count":0,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/468\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}