Introduction

Ironhide is an Object Oriented Android testing framework, written in Java, built on top of the Google Espresso testing framework. Ironhide provides an easier to use framework by handling some of the more complex elements of Espresso and Hamcrest matchers in the background, and providing the user with an easy way to create tests. A basic understanding of Google’s Espresso is recommended.

How does it work?

Ironhide is composed of Models and Page Elements. Models represent the various pages in your application. These Models are in turn populated by Page Elements that represent the various views and elements on the page. A test built with Ironhide will give the starting model and then chain together actions or assertions taken on page elements. Because of the nature of Ironhide, almost all tests can be made in one chain of actions, which results in tests being written much like they might be spoken. Here is an example, from the test app, of what a simple test might look like.

This is what the page looks like.

This is a model of the Simple Activity.

public class SimpleModel extends PageObject {
    public Clickable<SimpleModel> SimpleButton = new Clickable<>(SimpleModel.class, R.id.button_simple);
    
    public Clickable<SimpleModel> SimpleText = new Clickable<>(SimpleModel.class, R.id.text_simple);
    
    public TextField<SimpleModel> SimpleSendText = new TextField<>(SimpleModel.class, R.id.sendtext_simple);
    
    public Clickable<DisplayModel> SimpleSend = new Clickable<>(DisplayModel.class, R.id.send_simple);
    
    public SpinnerView<SimpleModel> SimpleSpinner = new SpinnerView<>(SimpleModel.class, R.id.spinner_simple);
    
    public ListAdapter<SimpleModel> SpinnerList = new ListAdapter<>(SimpleModel.class, String.class);
}

This is a test that uses the Simple Activity Model.

@Test
public void testTypingAndPressBack() {
  SimplePage
    .SimpleSendText.typeText(R.string.hello_world)
    .SimpleSendText.closeKeyboard()
    .SimpleSend.click()
    .displayText.withText(R.string.hello_world)
    .displayText.goesTo(SimpleModel.class).pressBack()
    .SimpleSendText.withText(R.string.hello_world)
;
}

This test does the following:

Setup

Before getting started make sure to read the Espresso Set Up Instructions here

  1. Download the JAR file.
  2. Put the Ironhide JAR in the libs folder in your app.
  3. Add androidTestCompile files('libs/Ironhide-1.X.X.jar') in the dependencies section of your build.gradle file

More Information

Ironhide Wiki

License

Copyright 2015 MINDBODY, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.