A simple Tabris/RAP Test Runner

A simple Tabris/RAP Test Runner

Writing JUnit Tests for an application is always a good thing. Writing tests for a Tabris or RAP application for the first time seems more challenging: You might encounter an “java.lang.IllegalStateException: No context available outside of the request processing.” exception while running the tests.
So, after a quick google you will find a blog post from my dear fellow Johannes that explains that you need to setup and teardown the test with the RAP Test Fixture. This looks like this:

<pre lang="java">
@Before
public void setUp() {
  Fixture.setUp();
}
  
@After
public void tearDown() {
  Fixture.tearDown();
}
</pre>

After writing these lines a thousand times or so it gets annoying. So, for this reason we have written a small Test Runner in Tabris that you can use to ease the development of Tests. It’s called RWTRunner and it’s hosted as a github gist.

<script src="https://gist.github.com/hstaudacher/9183339.js"></script>

Feel free to copy the runner to your own project. If you have any other helpers that ease the testing of Tabris/RAP applications please let us know in a comment.

2 Comments
  • Frank Appel
    Reply
    Posted at 10:20 am, February 24, 2014

    Just wondering if a JUnit Rule would work also. Just in case you have to use another Runner e.g. for parameterized tests

Post a Comment

Comment
Name
Email
Website