<feed xmlns='http://www.w3.org/2005/Atom'>
  <title>Marcin Erdmann's blog feed</title>
  <subtitle>Groovy, Grails, Geb...</subtitle>
  <link href='http://blog.proxerd.pl' rel='self'></link>
  <updated>2023-04-15T19:37:46Z</updated>
  <generator uri='http://gaelyk.appspot.com' version='1.1'>Gaelyk lightweight Groovy toolkit for Google App Engine</generator>
  <entry>
    <id>segregating-spock-specifications-with-spockconfig-groovy-and-annotations</id>
    <title>Including and excluding Spock specifications from execution using a configuration file</title>
    <link href='http://blog.proxerd.pl/article/segregating-spock-specifications-with-spockconfig-groovy-and-annotations'></link>
    <published>2013-09-10T10:30:00Z</published>
    <updated>2014-01-21T13:58:26Z</updated>
    <category term='Spock' scheme='http://blog.proxerd.pl/category/Spock'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;It's a common requirement to be able to execute just a subset of your tests in a given situation. Or just run the quick tests locally and run everything on CI. And &lt;a href="http://spockframework.org"&gt;Spock&lt;/a&gt; being an excellent testing framework obviously supports it.&lt;/p&gt;

&lt;p&gt;In the past I used Spock's &lt;code&gt;@IgnoreIf&lt;/code&gt; and &lt;code&gt;@Require&lt;/code&gt; built-in extensions to exclude/include certain specs under given conditions. An example usage for marking some tests to be only run as a part of the CI build could be:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@Require({System.properties.containsKey('ciBuild')})
class SlowSpec extends Specification { ... }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;@Require&lt;/code&gt; annotation takes a closure. When the closure evaluates to true the annotated specification will be executed otherwise it will be ignored. As you might expect it becomes pretty cumbersome to have to copy that closure body all over the place if you have several specifications that you wish to annotate. Not to even mention...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>using-remote-control-plugin-to-log-in-into-a-grails-application-with-spring-security-backed-authentication</id>
    <title>Using Remote Control plugin to log in into a Grails application with Spring Security backed authentication</title>
    <link href='http://blog.proxerd.pl/article/using-remote-control-plugin-to-log-in-into-a-grails-application-with-spring-security-backed-authentication'></link>
    <published>2013-05-28T11:00:00Z</published>
    <updated>2013-05-27T10:26:17Z</updated>
    <category term='Grails' scheme='http://blog.proxerd.pl/category/Grails'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;In my previous &lt;a href="http://blog.proxerd.pl/article/verifying-that-groovy-remote-control-endpoint-is-exposed-in-your-application"&gt;post&lt;/a&gt; I wrote about how much I like using grey box testing as a technique for writing functional tests. One common scenario where you could use it is to log in into the application in your tests without having to go to the login page and filling the credentials every single time you need to test something that is available only to logged in users of your system.&lt;/p&gt;

&lt;p&gt;Some people will argue that you shouldn't be logging in for every single test that needs the user to be authenticated to be performed. They will use different ways not to have to do so like stepwise Spock specifications or not clearing cookies between tests. But I don't agree with that and I'm happy to pay the price of that little bit of overhead. By starting every single tests from always the same, clear, consistent state, setting up all prerequisites and then clearing cookies and y...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>verifying-that-groovy-remote-control-endpoint-is-exposed-in-your-application</id>
    <title>Verifying that Groovy Remote Control endpoint is exposed in your application</title>
    <link href='http://blog.proxerd.pl/article/verifying-that-groovy-remote-control-endpoint-is-exposed-in-your-application'></link>
    <published>2013-05-22T12:00:00Z</published>
    <updated>2013-05-21T20:12:35Z</updated>
    <category term='Grails' scheme='http://blog.proxerd.pl/category/Grails'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;I'm a big fun of grey box functional testing of web applications. I understand grey box testing as setting up your test (for example bootstraping data in db that the test requires) programmatically instead of via the UI. Sometimes you will also want to do parts of your verification in this way.&lt;/p&gt;

&lt;p&gt;Some people use fixture endpoints for that but I'm not a fan of this solution for two reasons: the fixture code lives along your production code and fixture endpoints are a nightmare to maintain - what people end up doing is to have one endpoint with a lot of setup for all the tests which bootstraps a lot of data that is not essential to every single test... Oh, and there is one more reason - you want your test setup to live as close to your test as possible.&lt;/p&gt;

&lt;p&gt;There is a better solution to this problem available for JVM apps - &lt;a href="http://groovy.codehaus.org/modules/remote/"&gt;Groovy Remote&lt;/a&gt;. It provides an endpoint that allows you to send groovy closures to the remote app...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>new-in-gradle-1-6-task-ordering</id>
    <title>New in Gradle 1.6: task ordering</title>
    <link href='http://blog.proxerd.pl/article/new-in-gradle-1-6-task-ordering'></link>
    <published>2013-05-20T12:00:00Z</published>
    <updated>2013-05-19T18:04:42Z</updated>
    <category term='Gradle' scheme='http://blog.proxerd.pl/category/Gradle'></category>
    <summary type='html'>&lt;p&gt;Recently &lt;a href="http://www.gradle.org/docs/1.6/release-notes.html"&gt;Gradle 1.6&lt;/a&gt; has been released. I was lucky enough to get a lot of support from the Gradle team in the means of implementation guidance and code reviews for contributing a new feature: &lt;a href="http://www.gradle.org/docs/current/userguide/more_about_tasks.html#sec:ordering_tasks"&gt;task ordering&lt;/a&gt;. Currently it's an icubating feature (&lt;a href="http://www.gradle.org/docs/current/userguide/feature_lifecycle.html#sec:incubating_state"&gt;see here what it means&lt;/a&gt;) and only "must run after" ordering is supported, though it's highly likely that other rules, like for example "should run after" with a slightly less restrictive contract, are coming.&lt;/p&gt;

&lt;p&gt;Let's look at a trivial example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;task a
task b {
    mustRunAfter a
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Executing &lt;code&gt;gradle b&lt;/code&gt; will only execute &lt;code&gt;b&lt;/code&gt; but executing &lt;code&gt;gradle b a&lt;/code&gt; will first execute &lt;code&gt;a&lt;/code&gt; and then &lt;code&gt;b&lt;/code&gt;. So i...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>gradle-golo-plugin-released</id>
    <title>Gradle Golo Plugin released!</title>
    <link href='http://blog.proxerd.pl/article/gradle-golo-plugin-released'></link>
    <published>2013-04-23T11:43:00Z</published>
    <updated>2013-04-23T11:49:49Z</updated>
    <category term='Gradle' scheme='http://blog.proxerd.pl/category/Gradle'></category>
    <summary type='html'>&lt;p&gt;I'm happy to announce the first public release of Gradle Golo Plugin. The plugin allows to build and run code written in &lt;a href="http://golo-lang.org/"&gt;Golo&lt;/a&gt; using &lt;a href="http://gradle.org/"&gt;Gradle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can have a look at &lt;a href="https://github.com/golo-lang/gradle-golo-plugin/blob/master/README.md"&gt;the docs&lt;/a&gt; and the &lt;a href="https://github.com/erdi/gradle-golo-plugin-example"&gt;example project&lt;/a&gt; to learn how to use it.&lt;/p&gt;
</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>resizing-browser-window-in-geb-tests</id>
    <title>Resizing browser window in Geb tests </title>
    <link href='http://blog.proxerd.pl/article/resizing-browser-window-in-geb-tests'></link>
    <published>2013-04-08T14:30:00Z</published>
    <updated>2013-04-07T20:46:30Z</updated>
    <category term='Geb' scheme='http://blog.proxerd.pl/category/Geb'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;It sometimes proves useful to be able to resize browser window in your Geb tests. Up to not so long ago WebDriver (which is used by Geb to drive browsers) did not provide such a functionality and you had to resort to different hacks that never worked in all of the browsers, but thankfully nowadays it is pretty straightforward.&lt;/p&gt;

&lt;p&gt;To make sure that the browser window is maximised before any tests are executed we can add the following to the &lt;code&gt;driver&lt;/code&gt; closure in &lt;code&gt;GebConfig.groovy&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;driver = {
    def driverInstance = new FirefoxDriver()
    driverInstance.manage().window().maximize()
    driverInstance
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One of the possible usages of browser window resizing can be testing responsive sites. So for example if we want to write a specification that performs some tests on the site laid out as for an iPhone 4 and then maximise the site when done we could use the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class IPhone4Spec extends GebSpec {

    vo...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>mocking-browser-timers-in-geb-tests</id>
    <title>Mocking browser timers in Geb tests</title>
    <link href='http://blog.proxerd.pl/article/mocking-browser-timers-in-geb-tests'></link>
    <published>2013-04-05T19:00:00Z</published>
    <updated>2013-04-05T19:02:32Z</updated>
    <category term='Geb' scheme='http://blog.proxerd.pl/category/Geb'></category>
    <category term='Grails' scheme='http://blog.proxerd.pl/category/Grails'></category>
    <category term='Javascript' scheme='http://blog.proxerd.pl/category/Javascript'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;Functional tests are usually slow enough and you want to avoid any unnecessary waiting in them. But what should you do if the site you're testing is using animated elements? By simply putting &lt;code&gt;waitFor {}&lt;/code&gt; blocks to wait for the animation to finish you're just wasting precious time.&lt;/p&gt;

&lt;p&gt;But there is a simple solution - you can easily mock browser timers using &lt;a href="http://sinonjs.org/docs/#clock"&gt;sinon.js&lt;/a&gt;. Let's see how we can use it in Geb tests to make them faster when testing an example Grails application that contains a carousel.&lt;/p&gt;

&lt;p&gt;Assuming that we're using Resources plugin, we'll first need to define a resource module that contains sinon.js and a simple Javascript file that will trigger timer mocking:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;modules = {
    fakeTimer {
        resource '/js/test/sinon.js'
        resource '/js/test/fakeTimer.js'
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In &lt;code&gt;fakeTimer.js&lt;/code&gt; file we need to assign the mocked timer to a global variable so that we can t...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>setting-system-properties-for-the-default-junit-run-configuration-in-intellij-from-gradle</id>
    <title>Setting system properties for JUnit run configurations in Intellij using Gradle</title>
    <link href='http://blog.proxerd.pl/article/setting-system-properties-for-the-default-junit-run-configuration-in-intellij-from-gradle'></link>
    <published>2013-03-06T08:00:00Z</published>
    <updated>2013-03-05T21:37:55Z</updated>
    <category term='Gradle' scheme='http://blog.proxerd.pl/category/Gradle'></category>
    <category term='IntelliJ' scheme='http://blog.proxerd.pl/category/IntelliJ'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;There is one particular Gradle feature that I couldn't live without - IDE project generation. Firstly it means that there are no more IDE specific files in your repository. Secondly it is a perfect tool to easily and quickly generate IDE project configuration files in a repeatable and customisable manner.&lt;/p&gt;

&lt;p&gt;There are currently two IDE plugins that gradle ships with &lt;a href="http://www.gradle.org/docs/current/userguide/eclipse_plugin.html"&gt;Eclipse plugin&lt;/a&gt; and &lt;a href="http://www.gradle.org/docs/current/userguide/idea_plugin.html"&gt;IDEA plugin&lt;/a&gt;. In this post I will describe how to use the latter to customise the generated project configuration files for IntelliJ.&lt;/p&gt;

&lt;p&gt;There are three types of Intellij project configuration files - project files (.ipr), module files (.iml) and workspace files (.iws). While Gradle provides a DSL for modyfing those files (at least for project and module files) quite often you will have to revert to using &lt;code&gt;withXml {}&lt;/code&gt; hook to do n...</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>specifying-git-revision-using-commit-message</id>
    <title>Specifying git revisions using a commit message</title>
    <link href='http://blog.proxerd.pl/article/specifying-git-revision-using-commit-message'></link>
    <published>2013-03-04T14:30:00Z</published>
    <updated>2013-03-04T14:51:03Z</updated>
    <category term='Git' scheme='http://blog.proxerd.pl/category/Git'></category>
    <summary type='html'>&lt;p&gt;Sometimes when I want to rebase some commits in git I cannot be bothered to copy and paste commit hash or calculate how many commits behind HEAD the commit I want to rebase onto is to be able to use the &lt;code&gt;HEAD~N&lt;/code&gt; notation. &lt;/p&gt;

&lt;p&gt;Recently I've learned from &lt;a href="https://www.kernel.org/pub//software/scm/git/docs/gitrevisions.html"&gt;gitrevisions manual&lt;/a&gt; that you can also specify a git revision using the &lt;code&gt;:/&amp;lt;text&amp;gt;&lt;/code&gt; notation where &lt;code&gt;&amp;lt;text&amp;gt;&lt;/code&gt; is a regular expression applied against commit messages. Unfortunately it doesn't work with git rebase complaining that it expects a single revision. But you can always use &lt;a href="https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html"&gt;git rev-parse&lt;/a&gt; to resolve a git commit hash:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git rebase -i $(git rev-parse ":/some commit message")
&lt;/code&gt;&lt;/pre&gt;
</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
  <entry>
    <id>test-driving-gaelyk-application-talk-from-ggx-and-greach</id>
    <title>Test driving Gaelyk applications talk from GGX and Greach</title>
    <link href='http://blog.proxerd.pl/article/test-driving-gaelyk-application-talk-from-ggx-and-greach'></link>
    <published>2013-01-26T09:21:00Z</published>
    <updated>2013-01-26T09:29:51Z</updated>
    <category term='Gaelyk' scheme='http://blog.proxerd.pl/category/Gaelyk'></category>
    <category term='Talks' scheme='http://blog.proxerd.pl/category/Talks'></category>
    <category term='Testing' scheme='http://blog.proxerd.pl/category/Testing'></category>
    <summary type='html'>&lt;p&gt;The slides from my 'Test driving Gaelyk applications' I gave at Groovy and Grails eXchange 2012 and Greach 2013 are available &lt;a href="http://blog.proxerd.pl/talks/gaelyk-testing/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The example application is available at &lt;a href="https://github.com/erdi/yatda"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you missed it you can still see &lt;a href="http://skillsmatter.com/podcast/java-jee/testing-gaelyk-applications"&gt;the recording of the talk from GGX&lt;/a&gt;.&lt;/p&gt;
</summary>
    <author>
      <name>Marcin Erdmann</name>
    </author>
  </entry>
</feed>