Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2468

Tapestry & Cobertura

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.4, 5.3.8
    • Fix Version/s: None
    • Component/s: tapestry-ioc
    • Labels:
      None

      Description

      cobertura adds utility methods to test classes
      but tapestry throws RuntimeException when it finds these methods in a module class.

      Here is an example project using cobertura.

      package ru.alexlumpov.coberturatest;
      
      import org.apache.tapestry5.ioc.ServiceBinder;
      
      public class MyModule {
      
          public static void bind(ServiceBinder binder) {
              binder.bind(MyService.class);
          }
      }
      
      package ru.alexlumpov.coberturatest;
      
      public class MyService {
      
          public String getHello() {
              return "Hello";
          }
      }
      
      package ru.alexlumpov.coberturatest;
      
      import org.apache.tapestry5.ioc.Registry;
      import org.apache.tapestry5.ioc.RegistryBuilder;
      import org.junit.Assert;
      import org.junit.Test;
      
      public class MyServiceTest extends Assert {
      
      	@Test
      	public void testGetHello() {
      
      		Registry registry = RegistryBuilder.buildAndStartupRegistry(MyModule.class);
      		MyService service = registry.getObject(MyService.class, null);
      		assertEquals("Hello", service.getHello());
      	}
      }
      
      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      	<modelVersion>4.0.0</modelVersion>
      	<groupId>ru.alexlumpov</groupId>
      	<artifactId>coberturatest</artifactId>
      	<version>1.0-SNAPSHOT</version>
      	
      	<properties>
      		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      		<maven.compiler.source>1.6</maven.compiler.source>
      		<maven.compiler.target>1.6</maven.compiler.target>
      	</properties>
      	
      	<dependencies>
      		<dependency>
      			<groupId>org.apache.tapestry</groupId>
      			<artifactId>tapestry-ioc</artifactId>
      			<version>5.3.8</version>
      			<exclusions>
      				<exclusion>
      					<groupId>log4j</groupId>
      					<artifactId>log4j</artifactId>
      				</exclusion>
      				<exclusion>
      					<groupId>org.slf4j</groupId>
      					<artifactId>slf4j-log4j12</artifactId>
      				</exclusion>
      			</exclusions>
      		</dependency>
      		<dependency>
      			<groupId>junit</groupId>
      			<artifactId>junit</artifactId>
      			<version>4.12</version>
      			<scope>test</scope>
      		</dependency>
      	</dependencies>
      	
      	<build>
      		<plugins>
      			<plugin>
      				<groupId>org.codehaus.mojo</groupId>
      				<artifactId>cobertura-maven-plugin</artifactId>
      				<version>2.7</version>
      				<executions>
      					<execution>
      						<phase>package</phase>
      						<goals>
      							<goal>cobertura</goal>
      						</goals>
      					</execution>
      				</executions>
      			</plugin>
      		</plugins>
      	</build>
      </project>
      

      if you type

      mvn clean package

      you will see

      Running ru.alexlumpov.coberturatest.MyServiceTest
      Adding module definition for class org.apache.tapestry5.ioc.services.TapestryIOCModule
      Adding module definition for class ru.alexlumpov.coberturatest.MyModule
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.421 sec <<< FAILURE!
      Cobertura: Loaded information on 3 classes.
      Cobertura: Saved information on 3 classes.
      
      Results :
      
      Tests in error: 
        testGetHello(ru.alexlumpov.coberturatest.MyServiceTest): Module class ru.alexlumpov.coberturatest.MyModule contains unrecognized public methods: public static int[] ru.alexlumpov.coberturatest.MyModule.__cobertura_get_and_reset_counters(), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_classmap(net.sourceforge.cobertura.coveragedata.LightClassmapListener), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_classmap_0(net.sourceforge.cobertura.coveragedata.LightClassmapListener), public static void ru.alexlumpov.coberturatest.MyModule.__cobertura_init().
      
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
      
      There are test failures.
      

        Attachments

        1. coberturatest.zip
          4 kB
          Alex Lumpov

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
               alexlumpov Alex Lumpov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: