For me unit testing Javascript has been an issue for quite a while. Our backend server usually have a lot of tests at various levels but the Javascript service and view layers have been more or less neglected in terms of automated tests. Using Selenium is one option but if your UI is subject to [...]
Configuring Jasmine to work with Maven and JQuery Fixtures
April 17th, 2012 by Johan Haleby — Java, Testing
Tags: automated testing, jasmine, javascript, maven
Configure Morphia to work without a default constructor
February 28th, 2012 by Johan Haleby — Java, Tips & Tricks
In my current project we’re migrating our existing entity model to MongoDB and have turned to Morphia for mapping our Java objects to and from its MongoDB representation. Our Java entities are immutable and preferably we’d like to keep it that way. Morphia, like most other mapping frameworks, require us to have a default constructor [...]
Komarro – A new interesting mock framework for Java
February 13th, 2012 by Johan Haleby — Java, Testing
Mocking is a well-known and estabilished concept in our field of work as developers. There are a lot of frameworks for creating and setting up expectations on mock objects in all kinds of different languages. For me as a Java developer my introduction with mocking was through the EasyMock project. Due to the techincal limitations [...]
Tags: easymock, mocking, mockito, powermock, tdd
How to really fix the too many open files problem for Tomcat in Ubuntu
February 11th, 2012 by Johan Haleby — Tips & Tricks
A couple of days ago we ran into the infamous “too many open files” when our Tomcat web server was under load. There are several blogs around the internet that tries to deal with this issue but none of them seemed to do the trick for us. Usually what you do is to set the [...]
Simple Parsing of Complex JSON and XML Documents in Java
October 9th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
In this blog I’m going to demonstrate how to parse and validate more complex JSON and XML documents in Java using the REST Assured framework and the XmlPath and JsonPath components available in this framework. Since REST Assured is implemented in Groovy it can be really beneficial to take advantage of Groovy’s collection API. Let’s [...]
Multipart Form Data File Uploading Made Simple with REST Assured
September 15th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
From a client perspective it has always seemed to me that uploading a large file or stream to a server using multi-part form data encoding in Java is overly complex. To address this I implemented support for it in REST Assured 1.3. Example Let’s say you have a simple HTML page that performs file-uploading from [...]
Tags: automated testing, http, rest
Is your REST assured?
June 4th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
A couple of months ago I introduced a new open source Java framework for simple automated testing of REST/HTTP services called REST Assured. A lot of things have happended to the framework since then and it’s now better than ever. In this blog I’m going to summarize some of the most important new features that [...]
Tags: automated testing, Java, rest, test
PowerMock for Integration Testing
May 19th, 2011 by Johan Haleby — Java, Testing
A while ago I blogged about how to use the PowerMock Rule to bootstrap PowerMock without using a JUnit runner. A problem that you’ll likely run into sooner or later when using this approach in an integration test is the need to ignore certain classes or packages from being loaded by the PowerMock classloader using [...]
Tags: automated testing, junit, powermock, testng
PowerMock with unsupported frameworks such as JMock
December 28th, 2010 by Johan Haleby — Java, Testing, Tips & Tricks
Currently PowerMock builds on top of EasyMock and Mockito to provide mocking of e.g. static methods and final classes using a familiar API. What most people don’t know is that it’s pretty easy to benefit from PowerMock even for frameworks it doesn’t support. JMock is another popular mocking framework that PowerMock currently doesn’t support but [...]
Tags: automated testing, Java, jmock, powermock
Using PowerMock with Spring integration testing
December 28th, 2010 by Johan Haleby — Java, Testing
I quite often get the question if PowerMock can be used together with Spring integration testing or other frameworks that require a JUnit runner to bootstrap. The answer up until now has been somewhat ambiguous. The reason is that for the last year or so we’ve been working with a new way of bootstrapping PowerMock [...]
Tags: automated testing, frameworks, powermock
REST Assured – Or how to easily test REST services in Java
December 27th, 2010 by Johan Haleby — Java, Testing
Testing and validating REST services in Java is harder than in dynamic languages such as Ruby and Groovy. REST Assured is a Java DSL (built on top of HTTP Builder) that brings the simplicity of these languages into the Java domain. Example 1 – JSON Assume that a GET request to http://localhost:8080/lotto returns JSON as: [...]
Tags: automated testing, frameworks, Java, rest
Awaitility 1.3 – Scala and field support
October 20th, 2010 by Johan Haleby — Java, Testing
Awaitility is a Java based DSL that allows you to easily setup expectations for asynchronous code (if you’re new to Awaitility you can read an introduction here). Version 1.3 has just been released with a couple of new interesting features. Scala support First of all we now have support for Scala! This means that you [...]
Awaitility – Java DSL for easy testing of asynchronous systems
July 20th, 2010 by Johan Haleby — Java, Testing
Introduction Testing asynchronous systems is hard. Not only does it require handling threads, timeouts and concurrency issues, but the intent of the test code can be obscured by all these details. Awaility is a DSL that allows you to express expectations of a asynchronous system in a concise and easy to read manner. Simple example [...]
Tags: automated testing, concurrency, Java, open source
Classloader Deep-Cloning without Serialization
December 23rd, 2009 by Johan Haleby — Java, Testing
Background In PowerMock we’re using a custom classloader to byte-code manipulate classes that are normally not mockable to make them mockable. But when running a test case there may be some cases when the user needs to byte-code manipulate a certain class (X) in the first test method but needs to have the class unmodified [...]
Tags: classloader, deep-cloning, frameworks, junit, manipulate, open source, powermock, serialization, tools
PowerMock + TestNG = True
December 14th, 2009 by Johan Haleby — Java, Testing
After having it on our todo list for at least a year we’ve finally managed to integrate PowerMock with TestNG 5.11 as of PowerMock version 1.3.5. This is a big milestone of the project since we’ve now demonstrated that PowerMock is decoupled from both a specific test framework and a specific mock framework. The TestNG [...]
Tags: frameworks, open source, powermock, testng
