N. Ma
N. Ma

Reputation: 629

Integration Testing ServiceStack on MonoDevelop(Xamarin)

Hi I'm new to Mono and ServiceStack, and I'm having trouble running integration tests on Xamarin Studios on OSx.

I'm following the examples here AppHostListenerBaseTests.cs, but I can't get the test to pass.

    private const string listeningOn = "http://localhost:8080/";
    private myAppHost appHost; // extends AppHostHttpListenerBase

    [TestFixtureSetUp()]
    public void TestFixtureSetUp ()
    {
        appHost = new myAppHost ();
        appHost.Init ();
        appHost.Start (listeningOn);

        System.Console.WriteLine("ExampleAppHost Created at {0}, listening on {1}",
                                 DateTime.Now, listeningOn);
    }

    [TestFixtureTearDown()]
    public void TestFixtureTearDown ()
    {
        if (appHost == null)
            return;
        appHost.Dispose ();
        appHost = null;
    }

    [Test()]
    public void StartupWebService ()
    {
       html = listeningOn.GetStringFromUrl();
       Assert.That(html.Contains("The following operations are supported."));
    }

Mono will always throw the System.Net.WebException: The remote server returned an error(404).

It is confusing because building the entire web-service works fine. It starts up and arrives at the metapage, but attempting to run it in a test with the same code just breaks. I'm not sure if this is a problem with Xamarin on OSx, or that I am just missing something simple in my test cases. Has anyone dealt with a similar problem before?

Upvotes: 1

Views: 157

Answers (1)

Vfleitao
Vfleitao

Reputation: 58

On your case i assume you are not running the integration tests form an emulator, but from a real device.

If that is the case, its normal that you receive a 404 since http://localhost:8080/ probably only exists in your machine, not the phone.

Upvotes: 1

Related Questions