Forum Discussion

irinamorel's avatar
irinamorel
New Contributor
2 years ago

Automatic cancellation of a test case run

I encountered a problem with readyAPI, if I try to run a complete testcase I cannot do this, the run operation is automatically canceled, but if I try to run a step-by-step testcase it works. What could be the problem that cause this? I mention that I started having this problem after setting up more environments to run tests.

Thank you!

5 Replies

  • Yki's avatar
    Yki
    Contributor

    Do you have any logs which can suggest it was canceled. Maybe your endpoint is not correctly configured for that environment?

     

    I guess you don't have a Setup-Script which cancels the run ? ğŸ˜ (I have that for some testcases)

     

    def env = testRunner.testCase.testSuite.project.activeEnvironment.name
    
    if (env == 'Test') {
    
    } else {
    	testRunner.cancel("This testcase can be run only on Test. The active environment is: "+env+".")
    }

     

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 2

    Hello irinamorel,

     

    I have to make a few assumptions on your question...  I assume the testcase is stopping on an error in a test step and not just stopping for some unknown reason...  A little more information from a show of logging content would help a lot.  ReadyAPI does a good job at reporting errors in log.

     

    I don't think it is a problem with ReadyAPI.  Without other information to go on, is suspect it is just an item in the test case options that needs to be ticked...  In the Test Case Options dialog (get there from right clicking the test case or within the test case choosing the 'gear' icon), un-tick the "Abort on Error:" option and that should allow your test case to complete without stopping when an error is encountered. 

     

    There is also a section of the ReadyAPI Preferences that controls that feature for test cases created after it is toggled.  ReadyAPI Preferences | Testing | Default Test Case Options.  Switching it in the preferences does not retroactively switch the item in every test case, it only affects future creation.

     

    This item is probably what effects jjam also...  If you are not the person who has only worked in the project, then other people could have toggled it when they worked on it.  A department standard would help that situation.

     

    If you want to make sure that all test cases in the project continue or stop, you can crack each of them open and adjust that option.  You can build a helper script (someplace where it only runs when you manually run it) in the project that evaluates all the test cases in the suites you choose.  Below is sample that would do that.  Running it with slight modification would make sure you get them all without the need to manually interrogate each.

    log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" start...';
    log.info "";
    
    def testcaseCount = 0;
    def suiteTestcaseToChangeList = ['Aircraft Maint', 'Cycle Count', 'Supplier', 'Marketing Paid', 'Collection'];
    
    testRunner.testCase.testSuite.project.getTestSuiteList().each
    {
       log.info it.getName();
       if (it.getName() in suiteTestcaseToChangeList) {
          it.getTestCaseList().each
          {
             testcaseCount++;
             //Switch the parameter value to 'true' if you need to enable 'Abort on Error' option
             //Switch the parameter value to 'false' if you need to disable 'Abort on Error' option
             it.setFailOnError(true);
             log.info "   Changing " + it.getName();
          };
       };
    };
    log.info "testcaseCount.toString()=${testcaseCount.toString()}";
    
    log.info "";
    log.info 'Test Step "' + testRunner.runContext.currentStep.name + '" done...';

     

    Regards,

    Todd

    • irinamorel's avatar
      irinamorel
      New Contributor

      Hi TNeuschwanger 

      Thank you for your answer, but for me the test run does not stop because of an error, if I want to run a test case it does not start running, its run is automatically canceled from the first attempt to run it. instead, the test case can only be run if I run it step by step. if you have any solution or suggestion, can you help me with some ideas, please?
      Thank you

  • jjam's avatar
    jjam
    Contributor

    I also have this problem. Sometime one test case/suite will work and another wont. I just save all work and restart. It's another bug/feature of Ready/API.