<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>agimatec &#187; TeamCity</title>
	<atom:link href="http://www.agimatec.de/blog/tag/teamcity/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.agimatec.de/blog</link>
	<description>Clash of realities</description>
	<lastBuildDate>Tue, 22 Dec 2009 16:50:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Selenium-Flex-Tests with Maven</title>
		<link>http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/</link>
		<comments>http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 19:05:05 +0000</pubDate>
		<dc:creator>Simon Tiffert</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://www.agimatec.de/blog/?p=385</guid>
		<description><![CDATA[I wanted to integrate our Flex application with tests into our Maven build. A few days ago I moved the app to Flex 3 and changed the Maven Plugin from the Maven2 Flex Plugin to Flex-mojos. Now the artifacts are in the repository and you don&#8217;t need to install the Flex SDK to build the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.agimatec.de/blog/wp-content/uploads/2008/11/img_2340.jpg" alt="" title="london" width="300" height="225" class="alignleft size-medium wp-image-390" />I wanted to integrate our Flex application with tests into our Maven build. A few days ago I moved the app to Flex 3 and changed the Maven Plugin from the <a href="http://www.israfil.net/projects/mojo/maven-flex2-plugin/">Maven2 Flex Plugin</a> to <a href="http://blog.flex-mojos.info">Flex-mojos</a>. Now the artifacts are in the repository and you don&#8217;t need to install the Flex SDK to build the application.</p>
<p>We have written the application as a demo in the first place and now wanting to test it in the wild. Because we use Cairngorm the application is well structured and contains as view layer only minimal parts of logic. Yes, we could include unit tests, but integration tests are far more interesting (from my point of view). In a large code base it could happen, that because of refactoring some things are broken. No deal, if you have tests and a CI system. But in the Flex app there are just tiny parts which I could test in a normal unit test.</p>
<p>Okay, so it should be integration test. Sounds good and not too complicated. There should exist a lot of frameworks because a lot of people start to use BlazeDS and other stuff in Java environments. Just something to start the app, run some tests and get the result back in the CI system.</p>
<p>I started to search on google and was surprised. Most of the blog posts I have found on that topic are just two month old. And there are not so many posts about that topic. With the combination of those posts I figured out, how to solve that problem. What problem?</p>
<ul>
<li>Integration tests of our Flex app</li>
<li>Integrated in Maven</li>
<li>Should work together with Cairngorm (would be more complicated with some unit tests frameworks)</li>
<li>Could be Selenium (to start the app and run tests)</li>
<li>Should be integrated in our continuous integration server TeamCity</li>
<li>Could be written in Java</li>
</ul>
<p><span id="more-385"></span></p>
<p>First thanks to the <a href="http://www.blackpepper.co.uk/black-pepper-blog/Flex-acceptance-testing-and-continuous-integration.html">blog post of Julia at Blackpepper</a>. She opened my eyes how to work with Java and Flex in combination. It is the combination of the SeleniumFlexAPI, which integrates as Flex to Javascript bridge in your Flex application and FlashSelenium.</p>
<p><a href="http://sourceforge.net/projects/seleniumflexapi/">SeleniumFlexApi</a> is in one part a Flex library which needs to be included in your app and on the other part an extension to the Selenium IDE. I like the Flex part, because it makes it easy to dive over Javascript into the details of your Flex app. What I don&#8217;t really like is the Javascript extension. Yes, it is not only a Selenium IDE part and you can include it into the start of the Selenium Server, but it is far away from Java and Maven.</p>
<p><a href="http://code.google.com/p/flash-selenium/">FlashSelenium</a> is a piece of code which let&#8217;s you talk from Java over Selenium with your Flex app. The Java part is very handy, but you need to code into Flex, which methods you could call over your bridge. So I need to write special code, which opens the bridge. The SeleniumFlexAPI is much better in this part.</p>
<p>I liked the solution of the blog post and started to implement it.</p>
<p>First the pom.xml where you need to include the SeleniumFlexAPI (the scope cost me some time):</p>
<pre class="xml" name="code">&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;

   &lt;parent&gt;
        &lt;groupId&gt;agimatec&lt;/groupId&gt;
        &lt;artifactId&gt;assessor&lt;/artifactId&gt;
        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
        &lt;relativePath&gt;../pom.xml&lt;/relativePath&gt;
    &lt;/parent&gt;

  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;agimatec&lt;/groupId&gt;
  &lt;artifactId&gt;assessor-flexapp&lt;/artifactId&gt;
  &lt;packaging&gt;swf&lt;/packaging&gt;
  &lt;version&gt;${agimatec-assessor-version}&lt;/version&gt;
  &lt;name&gt;Assessor Flex Application&lt;/name&gt;
  &lt;url&gt;http://www.agimatec.de&lt;/url&gt;

  &lt;dependencies&gt;
    		 &lt;!--Flex SDK dependencies--&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;playerglobal&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;flex&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;framework&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;framework&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;resource-bundle&lt;/type&gt;
			&lt;classifier&gt;en_US&lt;/classifier&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;rpc&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;rpc&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;resource-bundle&lt;/type&gt;
			&lt;classifier&gt;en_US&lt;/classifier&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.adobe.flex.sdk&lt;/groupId&gt;
			&lt;artifactId&gt;utilities&lt;/artifactId&gt;
			&lt;version&gt;3.0.0.477&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
		&lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.adobe.cairngorm&lt;/groupId&gt;
      &lt;artifactId&gt;cairngorm-bin&lt;/artifactId&gt;
      &lt;version&gt;2.2.1&lt;/version&gt;
      &lt;type&gt;swc&lt;/type&gt;
    &lt;/dependency&gt;

      &lt;dependency&gt;
        &lt;groupId&gt;org.openqa.selenium&lt;/groupId&gt;
        &lt;artifactId&gt;flex-api&lt;/artifactId&gt;
        &lt;version&gt;0.22&lt;/version&gt;
        &lt;type&gt;swc&lt;/type&gt;
          &lt;scope&gt;internal&lt;/scope&gt;
      &lt;/dependency&gt;

		 &lt;!--FlexUnit dependencies--&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;flexunit&lt;/groupId&gt;
			&lt;artifactId&gt;flexunit&lt;/artifactId&gt;
			&lt;version&gt;0.85&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;flexunit.junit&lt;/groupId&gt;
			&lt;artifactId&gt;flexunit-optional&lt;/artifactId&gt;
			&lt;version&gt;0.85&lt;/version&gt;
			&lt;type&gt;swc&lt;/type&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;sourceDirectory&gt;src/main/flex&lt;/sourceDirectory&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;info.rvin.mojo&lt;/groupId&gt;
        &lt;artifactId&gt;flex-compiler-mojo&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
        &lt;configuration&gt;
          &lt;includeSources&gt;
            &lt;param&gt;${project.build.sourceDirectory}&lt;/param&gt;
          &lt;/includeSources&gt;
          &lt;locales&gt;
            &lt;param&gt;en_US&lt;/param&gt;
            &lt;param&gt;de_DE&lt;/param&gt;
          &lt;/locales&gt;
          &lt;debug&gt;true&lt;/debug&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;info.rvin.mojo&lt;/groupId&gt;
        &lt;artifactId&gt;asdoc&lt;/artifactId&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
<p>To get the Flex application compile with Maven you need to download the SeleniumFlexAPI and include the swc-file into your Maven repository, because it is (not yet) available on public repositories.</p>
<p>After compiling you can start the Selenium IDE and load the extension or go directly to FireBug and try to call the methods. Be aware, that the args-parameter is normally optional, but needs to be filled for the Javascript-Flex bridge (also cost me some time).</p>
<p>To call a method of your running application in Firefox fire up in FireBug&#8217;s console:</p>
<pre class="html" name="code">window.document['AppName'].getFlexExists('NameOfAnElement','');</pre>
<p>To test your application you need to know, what the name of your application is (can be found in the HTML calling the Flash file) and you need to give ids to your elements, because there is just an id locator at the moment.</p>
<p>If you are at this point we can now switch to the Java part with Selenium. Selenium is just Javascript when you are in the browser. So all you do is to call the Javascript function which you called before over Firebug. FlashSelenium is a good wrapper for that call which means that you don&#8217;t have to write normal strings into your Selenium commands. I like a little bit more comfort and wanted to wrap the SeleniumFlexAPI a little bit closer. Also there are some methods in the FlashSelenium you don&#8217;t need with this solution. So I started to implement my own little wrapper. Maybe it is also interesting for the SeleniumFlexAPI (if completed with all methods).</p>
<p>Here is the beginning of the code:</p>
<pre class="java" name="code">package com.agimatec.assessor.selenium;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class FlexSelenium {
    Selenium selenium;
    String flexApp;

    public FlexSelenium(String ip, int port, String browser, String url, String flexApp) {
        selenium = new DefaultSelenium(ip, port, browser, url);
        this.flexApp = flexApp;
    }

    public void start() {
        selenium.start();
    }

    public void open(String url) {
        selenium.open(url);
    }

    public void stop() {
        selenium.stop();
    }

    public String doFlexClick(String id) {
        return callFlexBridge("doFlexClick",id);
    }

    public boolean getFlexExists(String id) {
        return callFlexBridge("getFlexExists",id).equals("true");
    }

    private String callFlexBridge(String method, String id) {
        return callFlexBridge(method, id, null);
    }

    private String callFlexBridge(String method, String id, String args) {
        if(args == null || args.trim().equals("")) {
            args = "''";
        }
        return selenium.getEval("window.document['"+flexApp+"']."+method+"('"+id+"',"+args+");");
    }
}</pre>
<p>And now the test case is the only thing which is missing. I used TestNG because it can be easier configured in a Selenium environment (when it started to become more complicated with several browsers, plattforms, test suites, test groups &#8230;):</p>
<pre class="java" name="code">package com.agimatec.assessor.selenium;

import org.testng.annotations.Test;

public class AssessorTest {
    private final static String URL = "http://192.168.1.175:8080/assessor-webapp";
    FlexSelenium selenium;

    @Test
    public void setUp() throws InterruptedException {
        selenium = new FlexSelenium("192.168.1.254", 4444, "*firefox", URL, "Terminal");
        selenium.start();
        selenium.open(URL);
        while(!selenium.getFlexExists("videoPlayer")) {
            Thread.sleep(1000);
        }

        selenium.doFlexClick("videoPlayer");
        Thread.sleep(300);
        selenium.doFlexClick("enterUserModeButton");
        selenium.stop();
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Perfect Selenium Setup</title>
		<link>http://www.agimatec.de/blog/2008/10/perfect-selenium-setup/</link>
		<comments>http://www.agimatec.de/blog/2008/10/perfect-selenium-setup/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 14:15:45 +0000</pubDate>
		<dc:creator>Simon Tiffert</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://www.agimatec.de/blog/?p=369</guid>
		<description><![CDATA[It takes some time, but I&#8217;m now nearly happy with our Selenium setup. In this series I want to explain what goals existed and how we get a larger suite of Selenium tests running. You can find some posts around Selenium in this blog, but I want to get in more detail. Also there are [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.agimatec.de/blog/wp-content/uploads/2008/10/fotolia_1476264_xs.jpg"><img class="alignleft size-medium wp-image-371" title="crash test dummy" src="http://www.agimatec.de/blog/wp-content/uploads/2008/10/fotolia_1476264_xs.jpg" alt="" width="300" height="195" /></a>It takes some time, but I&#8217;m now nearly happy with our Selenium setup. In this series I want to explain what goals existed and how we get a larger suite of Selenium tests running.</p>
<p>You can find some posts around Selenium in this blog, but I want to get in more detail. Also there are some improvements to the solutions which could be really interesting if you start with Selenium or get an idea, how others deal with larger Selenium test suites. I will try to publish a new part every week, because there is so much to say, which wouldn&#8217;t fit into one single post.</p>
<p>Goals:</p>
<ul>
<li>Continuous integration of web application tests</li>
<li>Tests in different browsers</li>
<li>TestNG Setup</li>
<li>Integration in Maven2</li>
<li>Faster Selenium tests</li>
</ul>
<p>Tests:</p>
<ul>
<li>Running use cases of the web application</li>
<li>Running Javascript Unit Tests in different browsers</li>
<li>Take screenshots of the application</li>
</ul>
<p>I&#8217;m a web developer and no full-time tester, that&#8217;s why you should see the posts as support in an agile environment. There are different solutions and methods to test a web application, but I feel very comfortable with coding my tests and provide solutions which helps in the day-to-day work.</p>
<p>Until I will continue with the series, you can have a look at the previous posts:</p>
<ul>
<li><a href="http://www.agimatec.de/blog/2008/04/web20-oberflachen-testen/">Testing of Web 2.0 interfaces</a> (in german, but you will understand the code part)</li>
<li><a href="http://www.agimatec.de/blog/2008/07/robust-portlet-testing/">Robust portlet testing</a></li>
<li><a href="http://www.agimatec.de/blog/2008/07/selenium-ci-tests-with-teamcity/">Selenium CI tests with TeamCity</a></li>
<li><a href="http://www.agimatec.de/blog/2008/08/selenium-testing-of-massive-ajax-apps/">Selenium testing of massive Ajax Apps</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.agimatec.de/blog/2008/10/perfect-selenium-setup/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Selenium CI Tests with TeamCity</title>
		<link>http://www.agimatec.de/blog/2008/07/selenium-ci-tests-with-teamcity/</link>
		<comments>http://www.agimatec.de/blog/2008/07/selenium-ci-tests-with-teamcity/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 14:33:08 +0000</pubDate>
		<dc:creator>Simon Tiffert</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://www.agimatec.de/blog/?p=219</guid>
		<description><![CDATA[TeamCity&#8217;s build agents are great. You can build a grid of servers running your continuous integration tests. This speeds up the build process when there are many commits over the day. But there is another great feature of the grid: You can setup different environments for your builds. Think of Java version, operating system, databases [...]]]></description>
			<content:encoded><![CDATA[<p>TeamCity&#8217;s build agents are great. You can build a grid of servers running your continuous integration tests. This speeds up the build process when there are many commits over the day. But there is another great feature of the grid:</p>
<p>You can setup different environments for your builds. Think of Java version, operating system, databases and browsers.</p>
<p>These are great news for web frontend tests because you can setup a clean environment with all your needs. Just fire your Selenium-Rc with TestNG against this agent.</p>
<p>There is just one problem: You shouldn&#8217;t install the build agent for the browser tests as service. We setup a new Xen container for the tests and no browser was visible. It was in the TaskManager but won&#8217;t show our tests.</p>
<p>After searching in Google and asking (the really fast) JetBrains support the solution is to start the agent from the command line. To get the agent running after reboots just write a little bat file and place it in the autostart folder:</p>
<pre name="code" class="java">
cd C:\TeamCityAgent\bin\
agent.bat start
</pre>
<p>Another tipp is to install a VNC server, because if you are using remote desktop you are stealing the Windows session.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.agimatec.de/blog/2008/07/selenium-ci-tests-with-teamcity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
