Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borachio should not require 'withExpectations' #5

Open
alexnixon opened this issue Sep 26, 2011 · 1 comment
Open

Borachio should not require 'withExpectations' #5

alexnixon opened this issue Sep 26, 2011 · 1 comment

Comments

@alexnixon
Copy link

Under JUnit 3, almost all Borachio-enabled tests will take the form:

@Test // or @MediumTest and friends if using RoboGuice
def someTest {
    withExpectations {
        // set expectations
        // run test code
   }
}

It would be convenient if Borachio called resetExpectations and verifyExpectations automatically at the start and end of any methods annotated as tests.

@paulbutcher
Copy link
Owner

You can avoid the use of withExpectations by overriding setUp and tearDown as described here in the documentation:

setUp and tearDown

This is not the recommended approach, because JUnit calls tearDown even if a test fails, and exceptions in tearDown override exceptions thrown by the test. This will result in the original cause of the failure being masked.

override def setUp() {
  resetExpectations
}

override def tearDown() {
  verifyExpectations
}

def testSomething {
  // Setup expectations
  // Exercise code under test
}

But as that says, there are issues with it :-(

I'm not sure how I could make use of the @MediumTest etc annotations (which are an Android, not a JUnit3, thing). If you have any suggestions, I'd be delighted to hear them. There's no such thing (AFAIK) as a @Test annotation on Android, is there? That's JUnit4 (which isn't supported on Android). Or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants