在jbehave故事文件中注解故事情节

cygmwpex  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(209)

我想注解掉jbehave故事文件中的故事行,这样它们就不会运行了。我已经试过使用“!--”在我的故事文件中,如下所示:
我只想运行最后一个场景,因为您可以看到,我没有试图对其进行注解。但是,这不起作用,当我运行我的故事配置时,我会得到以下输出(附在我的故事文件下面)
我的故事文件:

!-- Scenario:Testing status code based on the body parameters
!-- Given the URL <URI> to which the post request is to be made
!-- When post request is made with or without <authorization> with body params <name> <description> and <owners>
!-- Then Status code should be <status>
!-- Examples:
!-- |URI|authorization|name|description|owners|status|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-001|Test1|null|201|
!-- |https://sandbox.predera.com/aiq/api/projects|false|project-002|Test2|null|401|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test3|pranav|201|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project 004|Test4|pranav|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-003_9.1111|Test5|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-004|""|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|""|""|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test6|pranav|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test3|pranav|400|
!--
!-- Scenario: Testing the content and contentType of a valid post call
!-- Given The URI
!-- When A valid post req is made to it
!-- Then the scenario must be true

Scenario:Testing the status code of the post models API
Given The models Post URI <URI>
When Post Req is made to this models POST API with/without authorisation <auth>
Then Status code is <status>, number of experiments is updated correctly as <count> and content type is <contentType>
Examples:
|URI|auth|status|count|contentType|
|https://sandbox.predera.com/aiq/api/models|false|401|3|content-type: application/problem+json|
|https://sandbox.predera.com/aiq/api/models|true|201|4|content-type: application/json|
|https://sandbox.predera.com/aiq/api/models|true|201|5|content-type: application/json|
|https://sandbox.predera.com/aiq/api/models|true|201|6|content-type: application/json|
|https://sandbox.predera.com/aiq/api/models|true|201|7|content-type: application/json|
|https://sandbox.predera.com/aiq/api/models|true|201|8|content-type: application/json|

输出:

Running story com.example.prederiq.PrederaAiq/projects/create_project_story.story
!--
(com.example.prederiq.PrederaAiq/projects/create_project_story.story)

Scenario: Testing status code based on the body parameters

!-- Given the URL <URI> to which the post request is to be made
!-- When post request is made with or without <authorization> with body params <name> <description> and <owners>
!-- Then Status code should be <status>
!-- Examples:
!-- |URI|authorization|name|description|owners|status|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-001|Test1|null|201|
!-- |https://sandbox.predera.com/aiq/api/projects|false|project-002|Test2|null|401|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test3|pranav|201|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project 004|Test4|pranav|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-003_9.1111|Test5|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-004|""|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|""|""|null|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test6|pranav|400|
!-- |https://sandbox.predera.com/aiq/api/projects|true|project-002|Test3|pranav|400|
!-- (PENDING)
!-- Scenario: Testing the content and contentType of a valid post call
!-- Given The URI
!-- When A valid post req is made to it
!-- Then the scenario must be true

我的故事文件配置:

public class CreateProjectStory  extends JUnitStories {
    @Override
    public Configuration configuration() {
        return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass())).withDefaultFormats().withFormats(StoryReporterBuilder.Format.CONSOLE, StoryReporterBuilder.Format.HTML));
    }

    @Override
    public InjectableStepsFactory stepsFactory() {
        return new InstanceStepsFactory(configuration(),new PrederaAiqApplicationTests());
    }

    @Override
    @Test
    public List<String> storyPaths() {
        return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()).getFile(), "**/create_project_story.story" ,"");
    }
    @Override
    @Test
    public void run() {
        try {
            super.run();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题