如何从外部Java库导入robot-file?

时间:2016-11-10 07:32:58

标签: java maven maven-plugin robotframework

我使用Java + Robot Framework来测试微服务。 所以我为每个服务创建了几个测试项目。 为了测试,我创建了一些带有关键字的java类,以便在低级别上使用HTTP和JSON。我将这些类分成了一个库,我计划将其作为maven依赖项添加到测试项目中。

另外,我想将常用关键字添加到此外部库的机器人文件中。

enter image description here

但问题是我无法在测试中导入这些机器人文件。

enter image description here

请注意第一张图片是外部项目,第二张图片是测试项目。

有没有人遇到过这样的问题,如果是的话,你有什么决定?

1 个答案:

答案 0 :(得分:0)

我设法通过maven插件应用hack。所以我只是复制当前项目中的资源。

<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
相关问题