简体   繁体   English

自动化的API稳定性测试

[英]Automated API stability testing

I have a webapp I want to test for API stability. 我有一个要测试API稳定性的webapp。

To test the API I have a dependency on the project containing the domain objects written by my API, I call the api and try to deserialize the objects (using spring RestTemplate) into the domain objects. 为了测试API,我对包含由我的API编写的域对象的项目有依赖性,我调用api并尝试将对象反序列化(使用spring RestTemplate)到域对象中。

When developing a new version of the API, a newer version of the domain object project will be used. 在开发API的新版本时,将使用域对象项目的新版本。 Here's a picture of the scenario: 这是场景的图片: 在此处输入图片说明

Now I want an automated way of running the test project against a given webapp on a build server (Jenkins in this case, using maven or ant). 现在,我想要一种在构建服务器上针对给定Web应用程序运行测试项目的自动化方法(在这种情况下,Jenkins使用maven或ant)。 The problem is that they share one dependency with different versions (so I can't build them together). 问题在于它们与不同版本共享一个依赖项(因此我无法将它们一起构建)。

My current approach is to build the webapp, deploy it in a jetty and then try to run the tests. 我当前的方法是构建Webapp,将其部署在码头上,然后尝试运行测试。 It has proven to be hard. 事实证明这很难。

Any takes on how to solve this issue? 如何解决这个问题? Previous experience? 以往的经验?

why does webapp-tests depend on domain 1.1 and webapp-api on 1.2-SNAPSHOT? 为什么webapp测试依赖于域1.1和1.2-SNAPSHOT上的webapp-api? shouldn't the webapp-tests artifact depend on the same common dependency as webapp-api? webapp-tests工件不应该依赖于与webapp-api相同的通用依赖项吗? If its the same artifact just with a different version you could configure that into a property. 如果只是不同版本的工件相同,则可以将其配置为属性。 But I think its better to also add webapp-api into the project so it shares the common version: 但我认为最好也将webapp-api添加到项目中,以便它共享通用版本:

  • domain (version) 域(版本)
  • webapp-api (depends on domain) webapp-api(取决于域)
  • webapp-tests (depends on domain, testing webapp-api) webapp-tests(取决于域,测试webapp-api)

all share the same parent and the same version. 都共享相同的父代和相同的版本。

if you want to test against the previous released version (or one of them) you need to do something similar to the cobertura-plugin: http://mojo.codehaus.org/cobertura-maven-plugin/ This would mean writing a plugin. 如果要测试先前发布的版本(或其中一个),则需要执行类似于cobertura-plugin的操作: http : //mojo.codehaus.org/cobertura-maven-plugin/这意味着编写插件。

Did you try to add the dependency you want to test into a maven profile so the webapp-tests run agains the webapp-api using different version of the domain? 您是否尝试将要测试的依赖项添加到Maven配置文件中,以便使webapp-tests使用不同版本的域再次运行webapp-api? so you could re-run the tests activating a different profile. 因此您可以重新运行测试以激活其他配置文件。

I might just get the question wrong :) If webapp-tests should contain a different version then dont let it depend on the webapp-api or domain project? 我可能只是把问题弄错了:)如果webapp-tests应该包含一个不同的版本,那么不要让它依赖于webapp-api或域项目吗? Since you do rest-testing there is no common classpath where the dependency could interfere? 由于您要进行剩余测试,因此没有公共类路径会在其中干扰依赖关系?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM