2016-11-10 80 views
0

我使用Java + Robot Framework来测试微服务。 所以我为每个服务创建了几个测试项目。 为了测试,我创建了几个包含关键字的java类,以便在低级别使用HTTP和JSON。我将这些类分离到一个库中,我计划将它添加到测试项目中作为maven依赖项。如何从外部java库导入机器人文件?

此外我想将常用关键字添加到此外部库的robot-file中。

enter image description here

但问题是,我不能在我的测试中导入这些机器人的文件。

enter image description here

,首先画面外的项目,第二张照片是测试项目,请注意。

有没有人遇到这样的问题,如果是的话,你有哪个决定?

+0

要打包了Java机器人关键词+通用机器人的关键字(机器人文件)到一个罐子,要导入的jar文件放进一个机器人测试用例文件。我对吗? –

+0

是的,你是对的。 – Seploid

+0

Gotcha!你能包括你收到的错误吗? (+如果你可以包含你试过的代码片段会更有帮助) –

回答

0

我设法应用黑客与maven插件。所以我只是复制当前项目中的资源。外部库的

<build> 
     … 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>unpack</id> 
         <phase>prepare-package</phase> 
         <goals> 
          <goal>unpack</goal> 
         </goals> 
         <configuration> 
          <artifactItems> 
           <artifactItem> 
            <groupId>prototype-apitesting</groupId> 
            <artifactId>apitesting</artifactId> 
            <version>${acceptence.test.library.version}</version> 
            <type>jar</type> 
            <includes>com.robot.common/*</includes> 
            <outputDirectory>${basedir}/src/main/resources</outputDirectory> 
           </artifactItem> 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

结构

├── java 
│   └── com 
│    └── robot 
│     └── sample 
│      └── keywords 
│       └── APITestingKeywords.java 
└── resources 
    └── com.robot.common 
     ├── Config.robot 
     ├── HttpAssertions.robot 
     └── keywords 
      ├── AccountServicesKeywords.robot 
      └── SessionServicesKeywords.robot