Giter Club home page Giter Club logo

nunit.xamarin's Introduction

NUnit 3.0 Xamarin Runners

NUnit test runners for Xamarin and mobile devices

How to Use

The NuGet packages are nearly ready and we will likely create project templates, but until that is done, you will need to build from source. For this, you will need a Xamarin trial or subscription.

  1. Clone this repository
  2. Open nunit.runner.sln in Visual Studio with Xamarin installed, or in Xamarin Studio.
  3. Create a release build of the solution.

Then in your solution;

  1. Add a new Blank App (Android) or Blank App (iOS) to your solution
  2. Add NuGet packages to your project for NUnit 3.0.0-beta-4 and Xamarin.Forms 1.4.4.6392
  3. Browse and add a reference to the nunit.runner.droid.dll or nunit.runner.ios.dll that you built
  4. Write your unit tests in this project, or in a shared project
  5. Change the base class of MainActivity on Android to global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
  6. Change the base class of AppDelegate on iOS to global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
  7. Change MainActivity.OnCreate() on Android or AppDelegate.FinishedLaunching() on iOS
  8. Build and run the tests on your device or emulator

Android

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

    // This will load all tests within the current project
    var nunit = new NUnit.Runner.App();

    // If you want to add tests in another assembly
    //nunit.AddTestAssembly(typof(MyTests).Assembly);

    // Do you want to automatically run tests when the app starts?
    nunit.AutoRun = true;

    LoadApplication(nunit);
}

iOS

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();

    // This will load all tests within the current project
    var nunit = new NUnit.Runner.App();

    // If you want to add tests in another assembly
    //nunit.AddTestAssembly(typof(MyTests).Assembly);

    // Do you want to automatically run tests when the app starts?
    nunit.AutoRun = true;

    LoadApplication(nunit);

    return base.FinishedLaunching(app, options);
}

nunit.xamarin's People

Contributors

rprouse avatar

Watchers

Tim Uy avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.