来自不同存储库的 运行 个测试用例是否可以用于 webdriverio/node?

Is running test case that comes from different repository possible for webdriverio/node?

如果有两个独立的存储库,包括 webdriverio/node 不同项目 A 和 B 的自动化测试,但项目 A 的一些测试需要 运行 覆盖项目 B 区域的测试,可以我们在属于项目 A 的测试中执行测试调用,这将 运行 从位于其他存储库的项目 B 进行测试?

我知道对于这种特殊情况,最快的解决方案就是 copy/paste 必要的代码,但我想知道我是否能够不通过 运行 特定的方式复制测试代码来自其他存储库的测试用例。

好吧,您可以将测试用例创建为函数,然后将其导入到您的项目中 A/B/whatever。

///// project A
function loginTestcases(){
 describe('Login', ()=>{
  it('Login with valid credentials', ()=>{
    //some tests
  })
 })
}

///// project B
// use it in your another project as 
logiTestcases();

但我个人不推荐这种方法。目前还不清楚你测试了什么,body 测试用例有什么等等。你的测试也应该是独立的——所以不依赖于其他测试用例。

检查这个:

Rule 10: Write Independent and Isolated Tests An important methodology of test authoring is creating self contained, independent flows. This allows to run tests in high parallelism, which is crucial for scaling the test suites. If, for example, you have 1,000 tests that run for a minute each, running them one by one will take more than 16 hours. Minutes, at full concurrency, can cut this testing time to 1 minute.

https://devops.com/10-rules-for-writing-automated-tests/