mercredi 27 janvier 2016

Exception from RobolectricTestRunner - NumberFormatException: For input string: "@"

I am getting the following exception while running the Junit testcase in android with roboelectric.

These are the dependencies configured in my pom.xml file:

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.8.1</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.easymock</groupId>
  <artifactId>easymock</artifactId>
  <version>3.1</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-core</artifactId>
  <version>1.4.11</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-module-junit4</artifactId>
  <version>1.4.11</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-reflect</artifactId>
  <version>1.4.11</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.powermock</groupId>
  <artifactId>powermock-api-easymock</artifactId>
  <version>1.4.11</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>com.pivotallabs</groupId>
  <artifactId>robolectric</artifactId>
  <version>1.2</version>
  <scope>test</scope>
</dependency>

Here is the whole exception stacktrace:

Time elapsed: 0.386 sec  <<< ERROR!
java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "@"
at com.xtremelabs.robolectric.res.ResourceLoader.init(ResourceLoader.java:158)
at com.xtremelabs.robolectric.res.ResourceLoader.setLayoutQualifierSearchPath(ResourceLoader.java:599)
at com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:367)
at com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:311)
at com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:278)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.NumberFormatException: For input string: "@"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1250)
at java.lang.Float.parseFloat(Float.java:452)
at com.xtremelabs.robolectric.res.DimenResourceLoader.convertRawValue(DimenResourceLoader.java:37)
at com.xtremelabs.robolectric.res.ResourceReferenceResolver.processResource(ResourceReferenceResolver.java:29)
at com.xtremelabs.robolectric.res.DimenResourceLoader.processNode(DimenResourceLoader.java:25)
at com.xtremelabs.robolectric.res.XpathResourceXmlLoader.processResourceXml(XpathResourceXmlLoader.java:27)
at com.xtremelabs.robolectric.res.DocumentLoader.loadResourceXmlFile(DocumentLoader.java:58)
at com.xtremelabs.robolectric.res.DocumentLoader.loadResourceXmlDir(DocumentLoader.java:52)
at com.xtremelabs.robolectric.res.DocumentLoader.loadSystemResourceXmlDir(DocumentLoader.java:43)
at com.xtremelabs.robolectric.res.ResourceLoader.loadSystemResourceXmlDir(ResourceLoader.java:285)
at com.xtremelabs.robolectric.res.ResourceLoader.loadValueResourcesFromDirs(ResourceLoader.java:274)
at com.xtremelabs.robolectric.res.ResourceLoader.loadDimenResources(ResourceLoader.java:210)
at com.xtremelabs.robolectric.res.ResourceLoader.init(ResourceLoader.java:140)
... 24 more

This exception is occuring in every test case class Setup method while loading up of the context(xml resource files).

Wondering whether it might be because of "@" symbol present in xml file like below could be causing the exception?

style="@style/heading_style"
android:id="@+id/submit_button"

Any leads would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire