Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.74 KB | None | 0 0
  1. <properties>
  2. <jbehave.version>4.0.4</jbehave.version>
  3. </properties>
  4. <dependencies>
  5. <dependency>
  6. <groupId>junit</groupId>
  7. <artifactId>junit</artifactId>
  8. <version>4.11</version>
  9. <scope>test</scope>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.jbehave</groupId>
  13. <artifactId>jbehave-core</artifactId>
  14. <version>${jbehave.version}</version>
  15. <scope>test</scope>
  16. </dependency>
  17. <dependency>
  18. <groupId>org.jbehave</groupId>
  19. <artifactId>jbehave-spring</artifactId>
  20. <version>${jbehave.version}</version>
  21. <scope>test</scope>
  22. </dependency>
  23. <dependency>
  24. <groupId>org.jbehave.site</groupId>
  25. <artifactId>jbehave-site-resources</artifactId>
  26. <version>3.1.1</version>
  27. <scope>test</scope>
  28. <type>zip</type>
  29. </dependency>
  30. <dependency>
  31. <groupId>org.jbehave</groupId>
  32. <artifactId>jbehave-core</artifactId>
  33. <version>${jbehave.version}</version>
  34. <classifier>resources</classifier>
  35. <type>zip</type>
  36. <scope>test</scope>
  37. </dependency>
  38. </dependencies>
  39. <build>
  40. ...
  41. <plugin>
  42. <groupId>org.apache.maven.plugins</groupId>
  43. <artifactId>maven-surefire-plugin</artifactId>
  44. <configuration>
  45. <scope>test</scope>
  46. <testSourceDirectory>${basedir}/src/test/java/</testSourceDirectory>
  47. <testClassesDirectory>${project.build.directory}/test-classes/</testClassesDirectory>
  48. <includes>
  49. <include>com/mycompany/myproject/test/behavior/steps/*.java</include>
  50. </includes>
  51. </configuration>
  52. </plugin>
  53.  
  54. <plugin>
  55. <groupId>org.jbehave</groupId>
  56. <artifactId>jbehave-maven-plugin</artifactId>
  57. <version>${jbehave.version}</version>
  58. <configuration>
  59. <scope>test</scope>
  60. </configuration>
  61. <executions>
  62. <execution>
  63. <id>unpack-view-resources</id>
  64. <phase>generate-resources</phase>
  65. <goals>
  66. <goal>unpack-view-resources</goal>
  67. </goals>
  68. </execution>
  69. <execution>
  70. <id>run-stories-as-embeddables</id>
  71. <phase>integration-test</phase>
  72. <configuration>
  73. <scope>test</scope>
  74. <includes>
  75. <include>com/mycompany/myproject/test/behavior/steps/*.java</include>
  76. </includes>
  77. <systemProperties>
  78. <property>
  79. <name>java.awt.headless</name>
  80. <value>true</value>
  81. </property>
  82. </systemProperties>
  83. </configuration>
  84. <goals>
  85. <goal>run-stories-as-embeddables</goal>
  86. </goals>
  87. </execution>
  88. </executions>
  89. <dependencies>
  90. <dependency>
  91. <groupId>log4j</groupId>
  92. <artifactId>log4j</artifactId>
  93. <version>1.2.17</version>
  94. <scope>compile</scope>
  95. </dependency>
  96. </dependencies>
  97. </plugin>
  98. </build>
  99.  
  100. $ mvn clean integration-test -e
  101. [INFO] Error stacktraces are turned on.
  102. [INFO] Scanning for projects...
  103. [INFO]
  104. [INFO] ------------------------------------------------------------------------
  105. [INFO] Building MyProject 0.1
  106. [INFO] ------------------------------------------------------------------------
  107. [INFO]
  108. [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MyProject ---
  109. [INFO] Deleting C:Usersmyloginmyprojecttarget
  110. [INFO]
  111. [INFO] --- jbehave-maven-plugin:4.0.4:unpack-view-resources (unpack-view-resources) @ MyProject ---
  112. [INFO] Unpacked C:Usersmylogin.m2repositoryorgjbehavesitejbehave-site-resources3.1.1jbehave-site-resources-3.1.1.zip to C:Usersmyloginmyprojecttargetjbehaveview
  113. [INFO] Unpacked C:Usersmylogin.m2repositoryorgjbehavejbehave-core4.0.4jbehave-core-4.0.4-resources.zip to C:Usersmyloginmyprojecttargetjbehaveview
  114. [INFO]
  115. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MyProject ---
  116. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  117. [INFO] Copying 18 resources
  118. [INFO] Copying 6 resources
  119. [INFO]
  120. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MyProject ---
  121. [INFO] Changes detected - recompiling the module!
  122. [INFO] Compiling 62 source files to C:Usersmyloginmyprojecttargetclasses
  123. ... omitted ...
  124. [INFO]
  125. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MyProject ---
  126. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  127. [INFO] Copying 6 resources
  128. [INFO]
  129. [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MyProject ---
  130. [INFO] Changes detected - recompiling the module!
  131. [INFO] Compiling 12 source files to C:Usersmyloginmyprojecttargettest-classes
  132. [INFO]
  133. [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ MyProject ---
  134. [INFO] Surefire report directory: C:Usersmyloginmyprojecttargetsurefire-reports
  135.  
  136. -------------------------------------------------------
  137. T E S T S
  138. -------------------------------------------------------
  139. Running com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
  140. Processing system properties {}
  141. Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=false,verboseFailures=true,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]
  142. Running story com/mycompany/myproject/test/behavior/steps/sample_rest_call_with_invalid_account_steps.story
  143. Generating reports view to 'C:Usersmyloginmyprojecttargetjbehave' using formats '[stats, ide_console, txt, html]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
  144. Reports view generated with 2 stories (of which 1 pending) containing 1 scenarios (of which 1 pending)
  145. Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.326 sec - in com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
  146.  
  147. Results :
  148.  
  149. Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  150.  
  151. [INFO]
  152. [INFO] --- maven-war-plugin:3.0.0:war (default-war) @ MyProject ---
  153. [INFO] Packaging webapp
  154. [INFO] Assembling webapp [MyProject] in [C:Usersmyloginmyprojecttargetmywarname##0.1]
  155. [INFO] Processing war project
  156. [INFO] Copying webapp resources [C:Usersmyloginmyprojectsrcmainwebapp]
  157. [INFO] Webapp assembled in [484 msecs]
  158. [INFO] Building war: C:Usersmyloginmyprojecttargetmywarname##0.1.war
  159. [INFO]
  160. [INFO] --- spring-boot-maven-plugin:1.3.5.RELEASE:repackage (default) @ MyProject ---
  161. [INFO]
  162. [INFO] --- jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) @ MyProject ---
  163. [INFO] Running stories as embeddables using embedder Embedder[storyMapper=StoryMapper,embedderMonitor=MavenEmbedderMonitor,classLoader=EmbedderClassLoader[urls=[/C:/Users/mylogin/Projects/AQ/aqservices/target/test-classes/, /C:/Users/mylogin/Projects/AQ/aqservices/target/classes/, spring-boot-starter-tomcat-1.3.5.RELEASE.jar, tomcat-embed-core-8.0.33.jar, tomcat-embed-el-8.0.33.jar, tomcat-embed-logging-juli-8.0.33.jar, tomcat-embed-websocket-8.0.33.jar, spring-ws-core-2.3.0.RELEASE.jar, spring-xml-2.3.0.RELEASE.jar, spring-aop-4.2.6.RELEASE.jar, spring-beans-4.2.6.RELEASE.jar, spring-core-4.2.6.RELEASE.jar, spring-oxm-4.2.6.RELEASE.jar, spring-web-4.2.6.RELEASE.jar, spring-webmvc-4.2.6.RELEASE.jar, spring-boot-starter-1.3.5.RELEASE.jar, spring-boot-1.3.5.RELEASE.jar, spring-boot-autoconfigure-1.3.5.RELEASE.jar, snakeyaml-1.16.jar, spring-boot-starter-log4j-1.3.7.RELEASE.jar, jcl-over-slf4j-1.7.21.jar, jul-to-slf4j-1.7.21.jar, slf4j-log4j12-1.7.21.jar, log4j-1.2.17.jar, spring-orm-4.3.2.RELEASE.jar, spring-jdbc-4.2.6.RELEASE.jar, spring-tx-4.2.6.RELEASE.jar, spring-data-commons-1.12.2.RELEASE.jar, spring-context-4.2.6.RELEASE.jar, spring-expression-4.2.6.RELEASE.jar, spring-context-support-4.1.4.RELEASE.jar, spring-test-4.2.6.RELEASE.jar, spring-security-core-4.1.1.RELEASE.jar, aopalliance-1.0.jar, spring-security-web-4.1.1.RELEASE.jar, spring-security-config-4.1.1.RELEASE.jar, jstl-1.2.jar, wsdl4j-1.6.3.jar, aspectjweaver-1.8.9.jar, jasypt-1.9.2.jar, xstream-1.4.9.jar, xmlpull-1.1.3.1.jar, xpp3_min-1.1.4c.jar, bcprov-jdk16-1.46.jar, org.apache.commons.io-2.4.jar, commons-io-2.4.jar, slf4j-api-1.7.21.jar, commons-lang-2.6.jar, mail-1.4.jar, activation-1.1.jar, dozer-5.5.1.jar, commons-beanutils-1.9.2.jar, commons-lang3-3.2.1.jar, jregex-1.2_01.jar, tomcat-embed-jasper-8.0.33.jar, ecj-4.5.jar, ehcache-2.10.2.2.21.jar, HikariCP-2.4.7.jar, emdq-1.0.jar, sqljdbc4-4.0.jar, ghs-verifyaq-client-1.0.3.jar, mockito-all-1.9.5.jar, junit-4.11.jar, hamcrest-core-1.3.jar, jbehave-core-4.0.4.jar, hamcrest-library-1.3.jar, hamcrest-integration-1.3.jar, commons-collections-3.2.2.jar, plexus-utils-3.0.10.jar, freemarker-2.3.23.jar, paranamer-2.4.jar, jbehave-spring-4.0.4.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:4.0.4, parent: sun.misc.Launcher$AppClassLoader@55f96302]],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]],embedderFailureStrategy=<null>,configuration=org.jbehave.core.configuration.MostUsefulConfiguration@645b2ac7,candidateSteps=<null>,stepsFactory=<null>,metaFilters=<null>,metaMatchers=<null>,systemProperties={java.awt.headless=true},executorService=<null>,executorServiceCreated=false,performableTree=PerformableTree,storyManager=<null>,timeoutParsers=<null>]
  164. [INFO] Found class names: [com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps]
  165. [INFO] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]]
  166. [INFO] Running embeddable com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
  167. [INFO] Processing system properties {java.awt.headless=true}
  168. [INFO] System property 'java.awt.headless' set to 'true'
  169. [INFO] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]]
  170. [INFO] Generating reports view to 'C:Usersmyloginmyprojecttargetjbehave' using formats '[stats, ide_console, txt, html]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
  171. [INFO] Reports view generated with 2 stories (of which 1 pending) containing 1 scenarios (of which 1 pending)
  172. [INFO] ------------------------------------------------------------------------
  173. [INFO] BUILD FAILURE
  174. [INFO] ------------------------------------------------------------------------
  175. [INFO] Total time: 12.714 s
  176. [INFO] Finished at: 2017-03-28T13:25:28-04:00
  177. [INFO] Final Memory: 38M/299M
  178. [INFO] ------------------------------------------------------------------------
  179. [ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) on project MyProject: Failed to run stories as embeddables: Failure in running embeddable: com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps: NullPointerException -> [Help 1]
  180. org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) on project MyProject: Failed to run stories as embeddables
  181. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
  182. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
  183. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
  184. at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
  185. at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
  186. at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
  187. at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  188. at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
  189. at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
  190. at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
  191. at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
  192. at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
  193. at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
  194. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  195. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  196. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  197. at java.lang.reflect.Method.invoke(Method.java:498)
  198. at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  199. at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  200. at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  201. at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  202. Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run stories as embeddables
  203. at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20)
  204. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
  205. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
  206. ... 20 more
  207. Caused by: org.jbehave.core.embedder.Embedder$RunningEmbeddablesFailed: Failure in running embeddable: com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
  208. at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:140)
  209. at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
  210. ... 22 more
  211. Caused by: java.lang.NullPointerException
  212. at org.jbehave.core.steps.spring.SpringStepsFactory.stepsTypes(SpringStepsFactory.java:39)
  213. at org.jbehave.core.steps.AbstractStepsFactory.createCandidateSteps(AbstractStepsFactory.java:34)
  214. at org.jbehave.core.embedder.PerformableTree$RunContext.<init>(PerformableTree.java:458)
  215. at org.jbehave.core.embedder.PerformableTree.newRunContext(PerformableTree.java:1105)
  216. at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:100)
  217. at org.jbehave.core.embedder.StoryManager.runStoriesAsPaths(StoryManager.java:86)
  218. at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213)
  219. at org.jbehave.core.junit.JUnitStory.run(JUnitStory.java:24)
  220. at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:131)
  221. ... 23 more
  222. [ERROR]
  223. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  224. [ERROR]
  225. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  226. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  227.  
  228. Scenario: Call the sample rest resource
  229. Given an initial value
  230. When this API is called
  231. Then expect failure
  232.  
  233. import com.mycompany.myproject.test.behavior.driver.AbstractSpringJBehaveStory;
  234. import com.mycompany.myproject.test.behavior.driver.annotations.BehaviorTest;
  235.  
  236. import org.jbehave.core.annotations.*;
  237. import org.junit.runner.RunWith;
  238. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  239.  
  240.  
  241. /**
  242. * Scenario: Call the sample rest resource
  243. */
  244. @RunWith(SpringJUnit4ClassRunner.class)
  245. @BehaviorTest
  246. public class SampleRestCallWithInvalidAccountSteps extends AbstractSpringJBehaveStory {
  247.  
  248. @Given("an initial value")
  249. public void Given() {
  250. // purposely empty
  251. }
  252.  
  253. @When("this API is called")
  254. public void When() {
  255. // purposely empty
  256. }
  257.  
  258. @Then("expect failure")
  259. public void Then() {
  260. // purposely empty
  261. }
  262. }
  263.  
  264. package com.mycompany.myproject.test.behavior.driver;
  265.  
  266. import java.util.Arrays;
  267.  
  268. import org.jbehave.core.configuration.Configuration;
  269. import org.jbehave.core.configuration.MostUsefulConfiguration;
  270. import org.jbehave.core.embedder.Embedder;
  271. import org.jbehave.core.embedder.EmbedderControls;
  272. import org.jbehave.core.io.CodeLocations;
  273. import org.jbehave.core.io.LoadFromClasspath;
  274. import org.jbehave.core.io.StoryLoader;
  275. import org.jbehave.core.io.StoryPathResolver;
  276. import org.jbehave.core.io.UnderscoredCamelCaseResolver;
  277. import org.jbehave.core.junit.JUnitStory;
  278. import org.jbehave.core.reporters.FilePrintStreamFactory;
  279. import org.jbehave.core.reporters.Format;
  280. import org.jbehave.core.reporters.StoryReporterBuilder;
  281. import org.jbehave.core.steps.InjectableStepsFactory;
  282. import org.jbehave.core.steps.ParameterControls;
  283. import org.jbehave.core.steps.spring.SpringStepsFactory;
  284. import org.springframework.beans.factory.annotation.Autowired;
  285. import org.springframework.context.ApplicationContext;
  286.  
  287.  
  288. public abstract class AbstractSpringJBehaveStory extends JUnitStory {
  289.  
  290. @Autowired
  291. private ApplicationContext appContext;
  292.  
  293. public AbstractSpringJBehaveStory() {
  294. Embedder embedder = new Embedder();
  295. embedder.useEmbedderControls(embedderControls());
  296. embedder.useMetaFilters(Arrays.asList("-skip"));
  297. useEmbedder(embedder);
  298. }
  299.  
  300. @Override
  301. public InjectableStepsFactory stepsFactory() {
  302. return new SpringStepsFactory(configuration(), appContext);
  303. }
  304.  
  305. @Override
  306. public Configuration configuration() {
  307. return new MostUsefulConfiguration()
  308. .useStoryPathResolver(storyPathResolver())
  309. .useStoryLoader(storyLoader())
  310. .useStoryReporterBuilder(storyReporterBuilder())
  311. .useParameterControls(parameterControls());
  312. }
  313.  
  314. private EmbedderControls embedderControls() {
  315. return new EmbedderControls()
  316. .doIgnoreFailureInStories(true)
  317. .doGenerateViewAfterStories(true)
  318. .doVerboseFailures(true);
  319. }
  320.  
  321. private StoryPathResolver storyPathResolver() {
  322. return new UnderscoredCamelCaseResolver();
  323. }
  324.  
  325. private StoryLoader storyLoader() {
  326. return new LoadFromClasspath();
  327. }
  328.  
  329. private StoryReporterBuilder storyReporterBuilder() {
  330. return new StoryReporterBuilder()
  331. .withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))
  332. .withPathResolver(new FilePrintStreamFactory.ResolveToPackagedName())
  333. .withFailureTrace(true)
  334. .withDefaultFormats()
  335. .withFormats(Format.IDE_CONSOLE, Format.TXT, Format.HTML);
  336. }
  337.  
  338. private ParameterControls parameterControls() {
  339. return new ParameterControls()
  340. .useDelimiterNamedParameters(true);
  341. }
  342. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement