ciscoheat / buddy

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

Allow boolean to be passed to `done()` to mark a test as passed or failed. #20

Closed brendanjerwin closed 10 years ago

brendanjerwin commented 10 years ago

Right now, the only way to mark a test as not pending is to actually assert.

Sometimes, I just want to see that my callback happened...

ciscoheat commented 10 years ago

I don't want to allow two ways to do the same thing, that can be confusing. What's the problem with just asserting?

brendanjerwin commented 10 years ago

I guess it'd have to be true.should.be(true)?

ciscoheat commented 10 years ago

That should do it. :)

brendanjerwin commented 10 years ago

Yeah... That works, but you don't think it's ugly/weird?

ciscoheat commented 10 years ago

It's more consistent and doesn't add extra features. Should be a quite temporary statement too, I assume?

brendanjerwin commented 10 years ago

I suppose the only time it'd be permanent is when the callback being tested has no parameters. Otherwise the values there would be tested.

ciscoheat commented 10 years ago

Hmm, testing callbacks sounds like a very low level testing for being BDD. Some data should be tested, otherwise it's not much of a test.

brendanjerwin commented 10 years ago

Well, another name for this style of testing is Context-Specification. Referring to the way the context is established followed by specifications.

I find this style of testing to be quite nice for test driving my work. BDD or not, this test framework is making my life better!

ciscoheat commented 10 years ago

Sure, I know about Context-Specification, if it's the same as When/Should (and similar to Given/When/Then). How do you structure such a test case using Buddy? It would be interesting to see.

brendanjerwin commented 10 years ago

Well, at the moment, since the before s don't 'stack' my tests stay pretty shallow. But, similar test suites, in coffee script on mocha, tend to grow deeper as the functionality gets more interesting. I use test file size as an indicator that my component may have too much to do. (SRP and all that...)

ciscoheat commented 10 years ago

If you have a link to some testing code, I'd be interested in taking a look. Closing this for now.

brendanjerwin commented 9 years ago

Just ran into another case where this behavior is weird.

Using mockatoo, I simply wanted to verify a mock method in the it. It kept showing up 'pending' until I did true.should.be(true)... Even calling done() wouldn't mark it as passed.

The behavior in mocha and jasmine is that a test is pending if it has no function, but passed if the provided function runs without exceptions. I think that behavior, or at least being able to call done() to indicate that the test did something, would be nice.

ciscoheat commented 9 years ago

Good idea, I've updated it now so a call to done() from a spec with no assertions will pass the test. Thanks. :)

brendanjerwin commented 9 years ago

Cool. A little bit more obvious now. Thx.