Clone wiki

monodroid-unittest / Home

Unit Testing Framework for MonoDroid

This project allows you to reuse your Visual Studio Unit Tests without modifications in your Mono for Android projects.

To use this project do the following:

  1. Add the "MonoDroidUnitTesting" project (from this repository) to your solution.
  2. Add a new Android Application project.
  3. Reference the "MonoDroidUnitTest" project in your new application.
  4. In your main activity, inherit from GuiTestRunnerActivity (instead of Activity) and implement the necessary methods.

That's it. When you run your application the tests you've specified in step 4 will be run.

Here's an example of how you can implement your main activity:

[Activity(Label = "MonoDroidUnit", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : GuiTestRunnerActivity {
  protected override TestRunner CreateTestRunner() {
    TestRunner runner = new TestRunner();
    // Run all tests from this assembly
    runner.AddTests(Assembly.GetExecutingAssembly());
    return runner;
  }
}

This will run all tests in the assembly (=project) of your main activity. Alternatively you can specify certain namespaces, single test class, and even single test methods to run. (Have a look at the overloads of AddTests().)

Screenshots

Overview over all tests Details on the result of a single test method

Updated