FileNotFoundException runs by JBehave (Maven project, IntelliJ)

First, I would like to say that I am a .Net developer who is temporarily working on a java project. I am very familiar with SpecFlow, and it looks like JBehave is very similar.

I am trying to get a basic history to run in my project, but everything I am trying to do seems to fail with the same exception.

java.io.FileNotFoundException: C:\Source\DataLoader\target\jbehave\storyDurations.props (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:120) at java.io.FileReader.<init>(FileReader.java:55) at org.jbehave.core.reporters.TemplateableViewGenerator.storyDurations(TemplateableViewGenerator.java:123) at org.jbehave.core.reporters.TemplateableViewGenerator.generateReportsView(TemplateableViewGenerator.java:115) at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:249) at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:237) at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213) at org.jbehave.core.junit.JUnitStories.run(JUnitStories.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runners.Suite.runChild(Suite.java:127) at org.junit.runners.Suite.runChild(Suite.java:26) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) 

The story and the steps themselves are linked to the following link:

https://blog.codecentric.de/en/2012/06/jbehave-configuration-tutorial/

with the following configuration:

 import org.jbehave.core.junit.JUnitStories; import java.util.Arrays; import java.util.List; public class simpleBDD extends JUnitStories { public simpleBDD() { super(); this.configuredEmbedder().candidateSteps().add(new ExampleSteps()); org.apache.log4j.BasicConfigurator.configure(); } @Override public List<String> storyPaths(){ return Arrays.asList("JBehave/Math.story"); } } 

This is a maven project, my pom looks like this:

 <?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>com.dh</groupId> <artifactId>dataloader</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.jbehave</groupId> <artifactId>jbehave-core</artifactId> <version>3.9.5</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-mapreduce-client-core</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.3</version> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> </dependency> <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> <version>0.98.4-hadoop2</version> </dependency> <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-server</artifactId> <version>0.98.4-hadoop2</version> </dependency> <dependency> <groupId>com.couchbase.client</groupId> <artifactId>couchbase-client</artifactId> <version>1.2.3</version> </dependency> </dependencies> 

This exception kills me, I tried many different configurations, but still the same error. The googling file which he complains does not give me answers ...

Does anyone know what I'm doing wrong? (please don't know java, maven and intellij)

+5
source share
3 answers

Solved! The problem was caused by the fact that my .story file was not copied to the target folder of the test classes, because it was not in the resources folder. Because JBehave could not find the story file, storyDurations.props was not created because the stories were not running.

As soon as I moved the .story file to resources, everything went fine.

+2
source

I don't know about such a problem, and JBehave could always write a history duration properties file when Stroy gets exceuted.

Also, the error seems to be more OS-specific rather than an error or problem in JBehave, therefore Windows OS.

Check the required resolution and the drive ( C:\ ) that you are trying to do as best as possible.

0
source

I tried so many ways, but still have not solved my problem. Finally, I removed spaces and wildcards from my path (including folder names), and then let me run the Test Runner.

0
source

Source: https://habr.com/ru/post/1206797/


All Articles