IGNITE-10828 GridAbstractTest calculates test count incorrectly - Fixes #5756.
authorEduard Shangareev <eshangareev@gridgain.com>
Thu, 27 Dec 2018 16:38:23 +0000 (19:38 +0300)
committerDmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Thu, 27 Dec 2018 16:38:23 +0000 (19:38 +0300)
Signed-off-by: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java

index 600985c..97791c9 100755 (executable)
@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
-import java.util.function.BiPredicate;
 import javax.cache.configuration.Factory;
 import javax.cache.configuration.FactoryBuilder;
 import org.apache.ignite.Ignite;
@@ -128,6 +127,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestRule;
 import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
@@ -2591,16 +2591,12 @@ public abstract class GridAbstractTest extends JUnit3TestLegacySupport {
 
                 if (this0.forceTestCnt)
                     cnt = this0.testCnt;
-                else {
-                    BiPredicate<Method, Class<? extends Annotation>> annotated
-                        = (m, cls) -> m.getAnnotation(cls) != null;
-
-                    cnt = 0;
-
-                    for (Method m : this0.getClass().getMethods())
-                        if (annotated.test(m, Test.class) && !annotated.test(m, Ignore.class))
-                            cnt++;
-                }
+                else
+                    cnt = (int)new TestClass(this0.getClass())
+                        .getAnnotatedMethods(Test.class)
+                        .stream()
+                        .filter(method -> method.getAnnotation(Ignore.class) == null)
+                        .count();
 
                 numOfTests = cnt;
             }