2016-11-10 79 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