if (shouldRun(each)) { return true;
@Test public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedMethodName() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testOther[1: ](com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedPackageName() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[1: ](com.tngtech.other.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHaveOnlyMethodNameAndEqualsExactly() { // Given: doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain(com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClass() { // Given: doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain 298zBZ=)& %(/$(=93A SD4)i(qzt)487 5z2 59isf&(com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHaveAdditionalMethodIdxAndMethodParamsAreDifferentButIdxIsEqual() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[1: test](com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClassButClassIsNotTheSame() { // Given: doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain 8zBZ=(qzt)487(com.tngtech.OtherClazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHaveAddtionalMethodIdxAndEqualsExcatly() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[1: ](com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedMethodIdx() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[2: ](com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClassButMethodNameIsNotTheSame() { // Given: doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testOther: test, 4(com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedClassName() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[1: ](com.tngtech.ClazzOther)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionHasNoMethodIdx() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain(com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHaveOnlyMethodNameAndEqualsExactlyWithoutPackage() { // Given: doReturn("Method testMain(Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain(Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnTrueWhenDescriptionHaveAdditionalMethodIdxAndEqualsMethodNameAndClass() { // Given: doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain[1: ](com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldReturnFalseWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClassButFilterHasIndex() { // Given: doReturn("Method testMain[2: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "testMain 1, 2, 3(com.tngtech.Clazz)"); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isFalse(); verify(filter).shouldRun(description); }
@Test public void testShouldRunShouldReturnTrueForMatchingChildDescription() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(false, "", setupDescription(true, "testMain[1: ](com.tngtech.Clazz)")); // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }
@Test public void testShouldRunShouldCallOriginalFilterShouldRunIfOriginalFilterDescriptionCannotBeParsed() { // Given: doReturn("invalid").when(filter).describe(); Description description = setupDescription(true, "test(com.tngtech.Clazz)"); // When: underTest.shouldRun(description); // Then: verify(filter).describe(); verify(filter).shouldRun(description); verifyNoMoreInteractions(filter); }
@Test public void testShouldRunShouldCallOriginalFilterShouldRunIfIsTestAndGivenDescriptionCannotBeParsed() { // Given: doReturn("Method test(com.tngtech.Clazz)").when(filter).describe(); Description description = setupDescription(true, "invalid"); // When: underTest.shouldRun(description); // Then: verify(filter).describe(); verify(filter).shouldRun(description); verifyNoMoreInteractions(filter); }
@Test public void testShouldRunShouldCallOriginalFilterShouldRunIfGivenDescriptionContainsOr() { // Given: doReturn("Matching description Method failing1[0: 0](Test1) OR Method failing2[0: 0](Test2)").when(filter) .describe(); Description description = setupDescription(true, "failing1[0: 0](Test1)"); // When: underTest.shouldRun(description); // Then: verify(filter).describe(); verify(filter).shouldRun(description); verifyNoMoreInteractions(filter); }
@Test public void testShouldRunShouldReturnTrueForMultipleChildDescriptionWithLastMatching() { // Given: doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe(); // @formatter:off Description description = setupDescription(false, "", setupDescription(true, "testOther[1: ](com.tngtech.ClazzOther)"), setupDescription(false, "testOther[1: ](com.tngtech.ClazzOther)"), setupDescription(true, "testMain[1: ](com.tngtech.Clazz)") ); // @formatter:on // When: boolean result = underTest.shouldRun(description); // Then: assertThat(result).isTrue(); }