Skip to content

Commit

Permalink
Allow exceptions to be thrown for smaller test-code footprint
Browse files Browse the repository at this point in the history
without try catch in order to get the correct exception upon failure of onSetUp and onTearDown.
  • Loading branch information
diba1013 authored and croesch committed Jul 17, 2019
1 parent 0d74888 commit cf5f202
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ public static final void setUpOnce() {
*
* @see #setUpRobot()
* @see #onSetUp()
* @throws Exception when the set up of the test fails which results in the complete test fails
*/
@Before
public final void setUp() {
public final void setUp() throws Exception {
setUpRobot();
onSetUp();
}

/**
* Subclasses need set up their own test fixture in this method. This method is called <strong>after</strong>
* executing <code>{@link #setUp()}</code>.
*
* @throws Exception when the set up of the test fails which results in the complete test fails
*/
protected abstract void onSetUp();
protected abstract void onSetUp() throws Exception;

/**
* Removes the <code>{@link FailOnThreadViolationRepaintManager}</code> again to allow EDT violating and EDT safe
Expand All @@ -69,9 +72,10 @@ public static final void tearDownOnce() {
*
* @see #cleanUp()
* @see #onTearDown()
* @throws Exception when the tear down of the test fails which results in that the test will not be cleaned up properly
*/
@After
public final void tearDown() {
public final void tearDown() throws Exception {
try {
onTearDown();
} finally {
Expand All @@ -82,7 +86,8 @@ public final void tearDown() {
/**
* Subclasses need to clean up resources in this method. This method is called <strong>before</strong> executing
* <code>{@link #tearDown()}</code>.
*
* @throws Exception when the tear down of the test fails which results in that the test will not be cleaned up properly
*/
protected void onTearDown() {
}
protected void onTearDown() throws Exception {}
}

0 comments on commit cf5f202

Please sign in to comment.