ciscoheat / buddy

Your friendly BDD testing library for Haxe!
MIT License
96 stars 24 forks source link

[C#] Doesn't report tests after first thrown exception #37

Closed azrafe7 closed 8 years ago

azrafe7 commented 9 years ago

To reproduce:

class Main {

    static function main() {
    var reporter = new ConsoleReporter();
    var runner = new SuitesRunner([new Test()], reporter);
    runner.run();
    }
}

class Test extends BuddySuite {

  public function new():Void {
    var x = 1;

    describe("test one", {

      it("fail", {
        throw "fail";
      });

      it("pass", {
        x.should.be(1);
      });

    });
  }
}

Neko output (correct):

X.
test one
  fail (FAILED: fail)
    @ Main.hx:26
  pass (Passed)
2 specs, 1 failures, 0 pending

C# output (missing report of second step):

X.
test one
  fail (FAILED: fail)

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
   at promhx.base.AsyncBase__handleError_159__Fun`1.__hx_invoke1_o(Double __fn_f
loat1, Object __fn_dyn1)
   at promhx.base.AsyncBase__handleError_176__Fun`1.__hx_invoke0_o()
   at promhx.base.EventLoop.f()
   at promhx.base.AsyncBase`1.immediateLinkUpdate[A,B](AsyncBase`1 current, Asyn
cBase`1 next, Function f)
   at promhx.Promise`1.then[A](Function f)
   at buddy.SuitesRunner.run()
   at EntryPoint__Main.Main()

Note that wrapping it in a try/catch will not solve the issue, but only prevent the stack trace to be logged.

ciscoheat commented 9 years ago

Thank you for a small and useful example! I see that you aren't using the ordinary way to execute the tests (implementing Buddy as the most examples show), did you try that as well?

azrafe7 commented 9 years ago

You're welcome!

class Main implements Buddy<[Test]> {}

I've just tried it and I get the same behaviour.

ciscoheat commented 9 years ago

Ok thanks, I'll take a look at it.

ciscoheat commented 8 years ago

Thank you, this helped to track down some C# issues. It's working now, with version 1.0.1. Please check it out!

ciscoheat commented 8 years ago

I'm quite sure this will work now when buddy has been rewritten, but please re-open if you still have problems.