Search code examples
node.jsgitlabwebdriver-io

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


If there are two separated repositories including webdriverio/node automation tests for different projects A and B, but some of the tests from project A require to run tests that covers area from project B, can we perform a test call inside test belonging to project A, that would run test from the project B, located on other repository?

I know for this particular case the quickest solution would be just copy/paste the necessary code, but I'm wondering whether I'm able not to duplicate the test code by running particular test cases from other repositories.


Solution

  • Well, you can creates testcases as functions and after that you can import it into your project 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();
    

    But personally I don't recommend this approach. It isn't clear what you test, what body testcase has etc. Also your test should be independent - so no dependencies on other testcases.

    Check this:

    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/