@Test public void shouldExportSuppliedCoverage() { final LocationBuilder loc = aLocation().withMethod("method"); final BlockLocationBuilder block = aBlockLocation().withBlock(42); final Collection<BlockCoverage> coverage = Arrays.asList( new BlockCoverage(block.withLocation( loc.withClass(ClassName.fromString("Foo"))).build(), Arrays.asList( "Test1", "Test2")), new BlockCoverage(block.withLocation( loc.withClass(ClassName.fromString("Bar"))).build(), Arrays.asList( "Test3", "Test4"))); this.testee.recordCoverage(coverage); final String actual = this.out.toString(); assertThat(actual).contains( "<block classname='Foo' method='method()I' number='42'>"); assertThat(actual).contains( "<block classname='Bar' method='method()I' number='42'>"); assertThat(actual).contains( "<tests>\n<test name='Test1'/>\n<test name='Test2'/>\n</tests>"); assertThat(actual).contains( "<tests>\n<test name='Test3'/>\n<test name='Test4'/>\n</tests>"); }
@Test public void shouldEscapeSpecialCharsInTestName() { final LocationBuilder loc = aLocation().withMethod("method"); final BlockLocationBuilder block = aBlockLocation().withBlock(42); final Collection<BlockCoverage> coverage = Arrays.asList( new BlockCoverage( block.withLocation(loc.withClass(ClassName.fromString("Foo"))).build(), Collections.singletonList("ParameterizedTest[case='Not so simple quotes']")), new BlockCoverage( block.withLocation(loc.withClass(ClassName.fromString("Foo"))).build(), Collections.singletonList("ParameterizedTest[case=\0 Null-Byte]")) ); testee.recordCoverage(coverage); final String actual = this.out.toString(); assertThat(actual).contains( "<tests>\n<test name='ParameterizedTest[case='Not so simple quotes']'/>\n</tests>"); assertThat(actual).contains( "<tests>\n<test name='ParameterizedTest[case=\\0 Null-Byte]'/>\n</tests>"); }
public static BlockLocationBuilder aBlockLocation() { return QB.builder(BlockLocationBuilder.class, blockLocationSeed()) .withBlock(1).withLocation(aLocation()); }