Skip to content

Commit

Permalink
Reduce redundancy concerning failures in @AfterAll-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Merdes authored and marcphilipp committed Nov 25, 2016
1 parent 88e122e commit 049dfc8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package org.junit.jupiter.migrationsupport.rules;

import static org.junit.jupiter.migrationsupport.rules.FailAfterAllHelper.fail;

import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -63,9 +65,4 @@ static void afterMethodsOfBothRulesWereExecuted() {
fail();
}

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.junit.jupiter.migrationsupport.rules;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.migrationsupport.rules.FailAfterAllHelper.fail;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -84,9 +85,4 @@ static void afterMethodsOfBothRulesWereExecuted() {
fail();
}

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.junit.jupiter.migrationsupport.rules;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.migrationsupport.rules.FailAfterAllHelper.fail;

import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -67,9 +68,4 @@ static void afterMethodsOfBothRulesWereExecuted() {
fail();
}

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package org.junit.jupiter.migrationsupport.rules;

import static org.junit.jupiter.migrationsupport.rules.FailAfterAllHelper.fail;

import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -73,9 +75,4 @@ static void afterMethodsOfBothRulesWereExecuted() {
fail();
}

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.junit.jupiter.migrationsupport.rules;

class FailAfterAllHelper {

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package org.junit.jupiter.migrationsupport.rules;

import static org.junit.jupiter.migrationsupport.rules.FailAfterAllHelper.fail;

import org.junit.Rule;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -57,9 +59,4 @@ static void afterMethodsOfBothRulesWereExecuted() {
fail();
}

static void fail() {
//hack: use this blacklisted exception to fail the build, all others would be swallowed...
throw new OutOfMemoryError("a postcondition was violated");
}

}

0 comments on commit 049dfc8

Please sign in to comment.