Run all my tests back to back

Asked by Ali Ahmed on 2021-01-14

So I've create several tests. There are all in separate sikuli folders and I've scripted it so it's generating a html reportat the end of the tests. I wanted to know if there is a way to run them back to back? right now I'm just running them individually.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1
Revision history for this message
Ali Ahmed (ali13xii) said :
#2

Ok so would I do it like this:

exitValue = runScript("/SikuliX/Viewing and Edit Trade.sikuli")
if exitValue > 1:
   print "there was a special case"
elif exitValue == 1:
   print "there was an exception"
else:
   print "ran with success"
exit(exitValue)

exitValue = runScript("/SikuliX/LinkTagToTrade.sikuli")
if exitValue > 1:
   print "there was a special case"
elif exitValue == 1:
   print "there was an exception"
else:
   print "ran with success"
exit(exitValue)

its just printing "there was a special case", but only prints it once. How would I do it exactly, I would appreciate help on this.

Revision history for this message
Ali Ahmed (ali13xii) said :
#3

I tried using this but its only running the first one once and it doesn't execute second test

runScript(r"C:\SikuliX\Viewing and Edit Trade.sikuli")

runScript(r"C:\SikuliX\LinkTagToTrade.sikuli")

Revision history for this message
RaiMan (raimund-hocke) said :
#4

This works for me:

https://www.dropbox.com/s/hi6tv4ldcsmyc5x/testRunScript.zip?dl=0

unzip somewhere and adjust baseFolder in main.py.

in comment #2 the exit(exitValue) (line 8) in any case ends the main script.

BTW: Recommendation: Never use filenames containing blanks or special characters, only characters, numbers, hyphen and underscore. (Viewing and Edit Trade.sikuli is bad)

Revision history for this message
Ali Ahmed (ali13xii) said :
#5

I tried that dropbox link but it didn't have any files in it. DO u have another link with code. I would like to see how u go it to work. I will make that adjustment to the sikuli folder names. I should just be able to rename the folder from windows explorer, that should be fine right?

Revision history for this message
RaiMan (raimund-hocke) said :
#6

Sorry, cleaned my DropBox ;-)

Will try to recover it tomorrow.

Revision history for this message
Ali Ahmed (ali13xii) said :
#7

Oh ok, I would really appreciate it.

Revision history for this message
RaiMan (raimund-hocke) said :
#8
Revision history for this message
Ali Ahmed (ali13xii) said :
#9

So I tried to do it using your code as reference and it only runs the first test. Here is what I have:

baseFolder = "C:\SikuliX"
s1 = "LinkTagToTrade.sikuli"
s2 = "AddDocumentToTrade.sikuli"

exVal = runScript(os.path.join(baseFolder, s1))
print s1, exVal

exVal = runScript(os.path.join(baseFolder, s2))
print s2, exVal

Revision history for this message
Ali Ahmed (ali13xii) said :
#10

Ok so I think its having issue because I'm using HtmlTest report for these tests. Here is code for LinkTagToTrade, would I need to change it to run it using Runscript?

import random
import shutil
import os

import utils
reload(utils)

import HTMLTestRunner
import unittest

class UITestCases(unittest.TestCase):

    def setUp(self):
        utils.openApplication("Adapt2ISO(CI)")

    def tearDown(self):

        utils.closeApplication()

    def test_1(self):

        utils.navigateToTradeCapture()
        utils.navigateToPowerRTEast()
        wait(30)

        utils.tradeChangeTradeDate("12/1/2020")

        utils.selectTrade()

        utils.clickOnLinkTag()

        utils.enterDateLinkTag("12/1/2020")

        initialTags=utils.getTradeIDInLinkTag()

        #takeScreenshot

        utils.takeScreenshot("InitialTags")

        utils.selectTagLinkTags()

        utils.clickLinkTagsInLinkTag()

        wait(1)

        finalTags=utils.getTradeIDInLinkTag()

        finalCount=utils.count_substring(finalTags,initialTags)

        print("Final Count is {}".format(finalCount))

        #TakeScreenShot

        utils.takeScreenshot("AfterTagsAdded")

        utils.exitLinkTag()

        #utils.selectTrade() First Trade should still be selected

        utils.clickOnLinkTag()

        tagsLinked=utils.getTradeIDInLinkTag()

        actualCount=utils.count_substring(tagsLinked,initialTags)

        print("Actual Count is {}".format(actualCount))

        if finalCount==actualCount :
            print("Tag Linked: Test Pass")
            print("Number of Tags that should be Linked {} and actual Tags that are Linked {}".format(finalCount,actualCount))
            utils.takeScreenshot("Link_Tags_To_Trade_Test_Results_PASS")
            print("See captured images in Result images folder")
            assert True
        else:
            print("Tag not Linked: Test Fail")
            print("inital count is {} and actual count is {}".format(initialTags,actualCount))
            utils.takeScreenshot("Link_Tags_To_Trade_Test_Results_FAIL")
            print("See captured images in Result images folder")
            assert False

        utils.clickUnLinkTagLinkTag()
        utils.exitLinkTag()

suite = unittest.TestLoader().loadTestsFromTestCase(UITestCases)
outfile = open("Link_Tags_To_Trade_Results.html", "w")
runner = HTMLTestRunner.HTMLTestRunner(stream = outfile, title = 'Link Tags to Trade testreport', description = 'NEW').run(suite)

Revision history for this message
RaiMan (raimund-hocke) said :
#11

--- description = 'NEW').run(suite)
does not look good ???

Try to close the outfile.

Revision history for this message
Ali Ahmed (ali13xii) said :
#12

What do you mean by "close the outfile"
What adjustment would I need to make?

Revision history for this message
RaiMan (raimund-hocke) said :
#13

Sorry to say: this is plain Python knowledge, which is essential when building more complex things with SikuliX scripts.

outfile = open("Link_Tags_To_Trade_Results.html", "w")
...
outfile.close()

Can you help with this problem?

Provide an answer of your own, or ask Ali Ahmed for more information if necessary.

To post a message you must log in.