forked from junit-team/junit4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request junit-team#304 from stefanbirkner/NonStaticInnerTe…
…stClass fixed issue junit-team#42 (error message for non-static inner class)
- Loading branch information
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/org/junit/tests/running/classes/BlockJUnit4ClassRunnerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.junit.tests.running.classes; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.junit.runners.BlockJUnit4ClassRunner; | ||
import org.junit.runners.model.InitializationError; | ||
|
||
public class BlockJUnit4ClassRunnerTest { | ||
public static class OuterClass { | ||
public class Enclosed { | ||
@Test | ||
public void test() { | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void detectNonStaticEnclosedClass() throws Exception { | ||
try { | ||
new BlockJUnit4ClassRunner(OuterClass.Enclosed.class); | ||
} catch (InitializationError e) { | ||
List<Throwable> causes= e.getCauses(); | ||
assertEquals("Wrong number of causes.", 1, causes.size()); | ||
assertEquals( | ||
"Wrong exception.", | ||
"The inner class org.junit.tests.running.classes.BlockJUnit4ClassRunnerTest$OuterClass$Enclosed is not static.", | ||
causes.get(0).getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters