cancel
Showing results for 
Search instead for 
Did you mean: 

Launch multiple tests from cmd

Contributor

Launch multiple tests from cmd

Hi,

i want to launch a "composition" of test from CMD , if l launch only one test it works . I use this command to launch one test : 

Start-Process -FilePath "$TestCompletePath" -ArgumentList "$ProjectPath /r /p:bSolid_DEV  /t:KeywordTests|Test1";

I want to run multiple tests in the same instance of TestComplete for this reason i can't do a cycle where for each iteration i launch a test in another instance of TestComplete.

Do you have any ideas to resolve this problem ?

 

Thanks

Emanuele

10 REPLIES 10
Community Hero

Re: Launch multiple tests from cmd

Create a single Keyword test that calls the other tests that you want and then call that via command line.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Launch multiple tests from cmd

This is a good idea but how can I create a KeywordTest and call the other tests from an external script ?

 

Community Hero

Re: Launch multiple tests from cmd


@egiacomi wrote:

This is a good idea but how can I create a KeywordTest and call the other tests from an external script ?

 


I'm not sure I understand the question.  You already demonstrated you know how to call a keyword test via commandline externally. 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Launch multiple tests from cmd

The tests i want to launch are every time different i can't create a "static KeywordTest" and than call it from an external script . Is there a way to launchmultiple tests from cmd ?

Community Hero

Re: Launch multiple tests from cmd

Not within the same session without writing some sort of code to make the distinction.  

 

Here's another potential solution:

 

1) Create a CSV file that lists out the test names that you want to execute

2) Create code in a script that uses the DDT.CSVDriver to read that CSV file and drive a loop through it

3) Each time through the loop, call the keyword indicated by the particular row in the CSV file.

4) Set your command line to execute that script code

 

Then, all you need to do to change the list of tests to execute is update the CSV file with the desired list.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Launch multiple tests from cmd

I think a solution like this, i write in a XML the test and the within a for loop i run all the tests .

Now i have a new problem :

This is my code :

def RunFailedTests():
Log.message("CreateLogFolderOnServer")
CreateLogFolderOnServer.CreateLogFolderOnServer()
Log.message("CleanLocalTestData")
ClearLocalTestData.CleanLocalTestData()
XmlFile = BuiltIn.ParamStr(6)
Log.Message("Tests failed : " + XmlFile)
if os.path.exists(XmlFile):
Log.message("Xml file exists")
else:
Log.message("Xml file doesn't exists")
return
Test_List = ParseXMLFile(XmlFile)
#CicloCheFaEseguireTuttiITestFalliti
for test in Test_List:
try:
    keywordTest.test.run()
except:
    log.message(Test error)
ExportLog.ExportLog()


def ParseXMLFile(XmlFile):
Test_List = []
root = ET.parse(XmlFile).getroot()
for test in root.findall('Tests/Test'):
#obtain ProjectTestItem
TestName = test.get('ProjectTestItem')
#add the test to the list

Test_List.append(TestName)
return Test_List

 

To run a keywordTest I should use this call : KeywordTest.TestName.Run() , the testname is contained in a variable how can i "take"the testname contained in the variable?

Community Hero

Re: Launch multiple tests from cmd

You're writing in Python...so I'm not sure a lot about it.

In JavaScript, JScript, or other C-based scripting languages in TestComplete, you can do the following

 

KeywordTests['Test1'].Run()

 

So, you could replace the KeywordTest name with the identifier you pull out of your XML.  I don't believe that is available in Python.

 

So, instead, you might need to do something like this

 

testToRun = eval('KeywordTest.' + testName)

testToRun.Run()


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Launch multiple tests from cmd

I solved this problem in this way .

for test in Test_List:
        try:
             strFunctionCall = aqString.Format("KeywordTests.%s.Run()",test)
             eval(strFunctionCall)
             Log.Message("Test : " + test + "has positive result")
        except:
            Log.Message("Test : " + test + "has negative result")

if a test failed the script doesn't go to the next iteration .. at the moment i haven't a solution,  do you have any ideas?

Highlighted
Community Hero

Re: Launch multiple tests from cmd

You're throwing an exception which probably throws an error into the log. You probably have "stop on error" turned on which is halting the project upon logging an error.  


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
New Here?
Join us and watch the welcome video:
SeptemberNews
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win