2014-11-13 22 views
5

Po pierwsze, chciałbym powiedzieć, że jestem programistą .Net, który tymczasowo pracuje nad projektem Java. Jestem bardzo zaznajomiony z SpecFlow i wydaje się, że JBehave jest bardzo podobny.FileNotFoundException z uruchomionym programem JBehave (Maven Project, IntelliJ)

Próbuję uzyskać podstawową historię, aby uruchomić w moim projekcie, ale wszystko staram się robić wydaje się niepowodzeniem z tego samego wyjątku

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) 

Historia i kroki są same z poniższego linku:

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

o następującej konfiguracji:

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"); 
} 
} 

Jest to projekt Maven, moja pom wygląda to lubi:

<?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> 

Wyjątek ten zabija mnie, próbowałem wielu różnych konfiguracjach, ale nadal ten sam błąd. Googlowanie pliku, na który narzeka, nie daje mi odpowiedzi ...

Ktoś ma pojęcie, co robię źle? (proszę zakładać, że nie ma wiedzy o java, maven i intellij)

+0

Rzeczywiście, jeśli spojrzeć na kod źródłowy w https://github.com/jbehave/jbehave-core/blob/master/jbehave-core/src/main/java/org/jbehave/core/reporters/TemplateableViewGenerator .java ten wyjątek jest przechwytywany i rejestrowany, ale kod może być kontynuowany. Jesteś pewien, że tak naprawdę nie działa? – CupawnTae

Odpowiedz

0

Nie jestem tego świadomy, a JBehave zawsze był w stanie napisać plik własności duracji fabularnych, gdy Stroy zostanie poddany egzekucji.

Ponadto, błąd wydaje się być specyficzny dla systemu operacyjnego bardziej niż błąd lub problem w zakresie JBehave, a tym samym system operacyjny Windows.

Sprawdź potrzebne pozwolenie i dysk (C:\), próbując to, co najlepsze, co mogę zasugerować.

2

Rozwiązany! Problem spowodowany jest tym, że mój plik .story nie został skopiowany do docelowego folderu klas testowych, ponieważ nie znajdował się w folderze zasobów. Ponieważ JBehave nie mógł znaleźć pliku historii, storyDurations.props nie został utworzony, ponieważ nie zostały uruchomione żadne artykuły.

Po przeniesieniu pliku .story do zasobów wszystko przebiegło poprawnie.

0

Próbowałem na wiele sposobów, ale wciąż nie rozwiązałem problemu. W końcu usunąłem spacje i znaki wieloznaczne z mojej ścieżki (w tym nazwy folderów), a następnie pozwolono mi na wykonanie Test Runner.

Powiązane problemy