Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: testing/android/junit/javatests/src/org/chromium/testing/local/GtestFilterTest.java

Issue 574433003: [Android] JUnit runner + gyp changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@deps-changes
Patch Set: fix findbugs issues Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: testing/android/junit/javatests/src/org/chromium/testing/local/GtestFilterTest.java
diff --git a/testing/android/junit/javatests/src/org/chromium/testing/local/GtestFilterTest.java b/testing/android/junit/javatests/src/org/chromium/testing/local/GtestFilterTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..7b0e0f5e2c09c53b239ff819f8edf071074df419
--- /dev/null
+++ b/testing/android/junit/javatests/src/org/chromium/testing/local/GtestFilterTest.java
@@ -0,0 +1,118 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.testing.local;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.Description;
+import org.junit.runner.RunWith;
+import org.junit.runner.manipulation.Filter;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+/**
+ * Unit tests for GtestFilter.
+ */
+@RunWith(BlockJUnit4ClassRunner.class)
+public class GtestFilterTest {
+
+ @Test
+ public void testDescription() {
+ Filter filterUnderTest = new GtestFilter("TestClass.*");
+ Assert.assertEquals("gtest-filter: TestClass.*", filterUnderTest.describe());
+ }
+
+ @Test
+ public void testNoFilter() {
+ Filter filterUnderTest = new GtestFilter("");
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testPositiveFilterExplicit() {
+ Filter filterUnderTest = new GtestFilter("TestClass.testMethod");
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testPositiveFilterClassRegex() {
+ Filter filterUnderTest = new GtestFilter("TestClass.*");
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testNegativeFilterExplicit() {
+ Filter filterUnderTest = new GtestFilter("-TestClass.testMethod");
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testNegativeFilterClassRegex() {
+ Filter filterUnderTest = new GtestFilter("-TestClass.*");
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testPositiveAndNegativeFilter() {
+ Filter filterUnderTest = new GtestFilter("TestClass.*-TestClass.testMethod");
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+ @Test
+ public void testMultiplePositiveFilters() {
+ Filter filterUnderTest = new GtestFilter(
+ "TestClass.otherTestMethod:OtherTestClass.otherTestMethod");
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "otherTestMethod")));
+ }
+
+ @Test
+ public void testMultipleFiltersPositiveAndNegative() {
+ Filter filterUnderTest = new GtestFilter("TestClass.*:-TestClass.testMethod");
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "testMethod")));
+ Assert.assertTrue(filterUnderTest.shouldRun(
+ Description.createTestDescription("TestClass", "otherTestMethod")));
+ Assert.assertFalse(filterUnderTest.shouldRun(
+ Description.createTestDescription("OtherTestClass", "testMethod")));
+ }
+
+}
+

Powered by Google App Engine
This is Rietveld 408576698