simplifiable assertions for junit 5: tests

This commit is contained in:
Anna.Kozlova
2016-10-19 16:46:49 +02:00
parent b4c7771a96
commit cb08eabbc0
5 changed files with 47 additions and 0 deletions
@@ -0,0 +1,9 @@
import org.junit.jupiter.api.Assertions;
class MyTest {
{
Assertions.assertTrue(foo(), () -> "message");
}
boolean foo() {return false;}
}
@@ -0,0 +1,7 @@
class MyTest {
{
org.junit.jupiter.api.Assertions.assert<caret>Equals(true, foo(), () -> "message");
}
boolean foo() {return false;}
}
@@ -0,0 +1,9 @@
import org.junit.jupiter.api.Assertions;
class MyTest {
{
Assertions.assertEquals(foo(), foo(), () -> "message");
}
Object foo() {return null;}
}
@@ -0,0 +1,9 @@
import org.junit.jupiter.api.Assertions;
class MyTest {
{
Assertions.assert<caret>True(foo().equals(foo()), () -> "message");
}
Object foo() {return null;}
}
@@ -28,6 +28,8 @@ public class SimplifiableJUnitAssertionFixTest extends IGQuickFixesTestCase {
public void testJUnit4TestCase() { doTest(); }
public void testIntegerPrimitive() { doTest(); }
public void testDoublePrimitive() { doTest(); }
public void testEqualsToTrueJUnit5() { doTest(); }
public void testTrueToEqualsJUnit5() { doTest(); }
@Override
protected void setUp() throws Exception {
@@ -67,5 +69,16 @@ public class SimplifiableJUnitAssertionFixTest extends IGQuickFixesTestCase {
"@Retention(RetentionPolicy.RUNTIME)" +
"@Target({ElementType.METHOD})" +
"public @interface Test {}");
myFixture.addClass("package java.util.function; public interface Supplier<T> { T get();}");
myFixture.addClass("package org.junit.jupiter.api;\n" +
"import java.util.function.Supplier;\n" +
"public final class Assertions {\n" +
" public static void assertEquals(Object expected, Object actual) {}\n" +
" public static void assertTrue(boolean expected) {}\n" +
" public static void assertEquals(Object expected, Object actual, Supplier<String> message) {}\n" +
" public static void assertTrue(Object expected, Supplier<String> message) {}\n" +
"}");
}
}