Sign in to follow this  
Followers 0
Rishav

Creating a test Case suite architecture [SOLVED]

9 posts in this topic

#1 ·  Posted (edited)

Hi folks.

During the weekends, I thought about making a test framework for our product but ran into some issues.

This is the current architecture I have in mind.

Posted Image

Posted Image

There will be a gui which saves the user settings in an ini file.

When the user clicks on the continue button on the gui, the gui closes after invoking the main au3 file. This will be the master file whose main job will be to control and coordinate the actual automation files.

Depending on the user settings, the main file will invoke and run the separate test case sets in any order.

My problems here are;

1. How do I invoke, ie run another autoit script from one script? Currently I am thinking of simply using the Run command, but it strikes me as rather inelegant and I will have to ensure that all the machines and users have set their script file to Run and not open.

2. How do I park the main script while execution on a different script is going on. Ie, once the execution of the test case 1 is over, the control is passed over to the main file again which may then any other script.

3. Currently I am thinking of running multiple scripts at once using global variable and while do loops. Say, main script invokes tc1 script and sets a global var $x =1.

A while $x=0 do loop, stalls the main script. At then very end of the tc1 script, I set $x=0 so that the main script proceeds ahead again. May or may not work, but again it feels extremely inelegant.

Can someone please advise a fellow OCD sufferer on these question and in general, offer sage on this endeavor.

thanks and regards.

Edited by Rishav

Share this post


Link to post
Share on other sites



1. How do I invoke, ie run another autoit script from one script? Currently I am thinking of simply using the Run command, but it strikes me as rather inelegant and I will have to ensure that all the machines and users have set their script file to Run and not open.

The Run function requires an executable (EXE, BAT, COM, or PIF) so the file association isn't important.

Each compiled AutoIt script contains the script interpreter, so you can use that to run uncompiled scripts.

If you were to use ShellExecute, which can be used to launch an uncompiled script directly, you can get around the association by specifying the proper verb. However, this would still require that AutoIt be installed or at least registered to handle the .AU3 extension.

2. How do I park the main script while execution on a different script is going on. Ie, once the execution of the test case 1 is over, the control is passed over to the main file again which may then any other script.

3. Currently I am thinking of running multiple scripts at once using global variable and while do loops. Say, main script invokes tc1 script and sets a global var $x =1.

A while $x=0 do loop, stalls the main script. At then very end of the tc1 script, I set $x=0 so that the main script proceeds ahead again. May or may not work, but again it feels extremely inelegant.

No need for loops, just use RunWait().

OCD answer:

For $iX = 1 To 3
    RunWait(@AutoItExe & " /AutoIt3ExecuteScript TC" & $iX & ".au3",@ScriptDir)
Next

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

guess it wasn't really an intermediate level problem. o.0

Thanks a lot, bro. will play with the things you pointed out. the Runwait command seems perfect for me.

One very basic I have is what is the difference between shell execute and Run? Don't both use the windows explorer to execute the file?

Edited by Rishav

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

... One very basic [question] I have is what is the difference between shell execute and Run? Don't both use the windows explorer to execute the file?

Not so basic... see if this makes sense:

ShellExecute uses:

the default application [as defined by the operation system (OS)]

and default verb [as defined by the default application]

to act on the au3 file.

The default application then acts upon the au3 file in a way that has been predefined.

You can specify the verb that you want ShellExecute to pass to the OS

which it in turn passes to the default application,

but you cannot know for sure:

what the default application is [it is not always "explorer"]

what the default verb is within this default application

what the verb is setup to do within this default application

unless you check all of that first.

[i.e. run the au3 file or open it for editing*]

Run (and RunWait) will use whatever app that you tell it to use and (depending on how you construct your Run line), the result will be that the au3 file runs.

In case the above info was as clear as mud - let me restate it:

ShellExecute could be told to act on an au3 file.

It would pass the file to the OS's default file handling shell.

The "shell's" default action can be setup to do different things:

It could run the script (like you assumed).

It could open the script for editing.

It could do whatever it was setup to do.**

Okay - now on to the main point:

If you use ShellExecute to act upon an au3 file, AutoIt would have to be installed on the computer in order for the au3 file to run. You could "FileInstall" AutoIt from your main script, but there is no need to do this because the main script (if it is compiled) already contains everything it needs in order to run the au3 script.

What Skruge said to do was to use Run and tell it to reuse the info already inside the main compiled script to run the au3 files.... much simpler.

~hope this helps~

*I'm aware that "edit vs. run" is usually handled by making a default verb, but the action within that verb may not be what you think.

**I have AV software that assigns all file extensions (and all files w/o extensions) to be "run" (scanned) by itself if they are found during a scan and are not assigned to another app. So the user may not even be aware of the action the default file shell is setup to do.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks plato. That was a great help.

The community here is seriously fantastic. Everytime I have asked for help, I have received it in spades. Kudos all around.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry to pull up this old thread but I need some more pointers here.

I have two script files;

A.au3 and B.au3.

B.au3 contains

Msgbox(0,"","Close")

I need to run B.au3 from A.au3.

I have put in a code similar to

Run("B.au3", "c:\test\")

in the A.au3 file.

Expectation is that, the user runs A.au3 and gets the popup box that was contained in B.au3.

Running A.au3 however, has no effect. Popup never comes. I have tried several variations with the runas, shellexecute etc commands as well.

one point here is that both scripts are uncompiled and will have to left as such to allow other people to modify whenever they want to.

secondly, I simply cannot assume whether they have set autoit to open or run the script on invoking an au3 file.

some help here will be very much appreciated.

-----------------------------------------------------------

OK. Found it. can't believe that I spent over an hour over this.

ShellExecute("Main.au3", "","","Run")

the problem was that the documentation doesn't mentions the run verb so I never tried it.

I tried the other verbs and ws playing around with stouts and such when I thought of trying my own verb and it worked.

Edited by Rishav

Share this post


Link to post
Share on other sites

-snipped-

Expectation is that, the user runs A.au3 and gets the popup box that was contained in B.au3.

Running A.au3 however, has no effect. Popup never comes. I have tried several variations with the runas, shellexecute etc commands as well.

one point here is that both scripts are uncompiled and will have to left as such to allow other people to modify whenever they want to.

secondly, I simply cannot assume whether they have set autoit to open or run the script on invoking an au3 file.

-snipped-

As Skruge said, Run() will only work on executable files (EXE, BAT, COM, or PIF). The (more) correct way to run a AutoIt script would be:

Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\B.au3"')

@AutoItExe will point to AutoIt.exe if you have not compiled the script, but if it is compiled it will point to the script itself, since the interpreter is there. Thus you won't need to install AutoIt on every computer that runs it, you only need to compile A.au3 (or leave both as scripts since it will work the same!)

Share this post


Link to post
Share on other sites

Thanks Admiral. I figured it out myself. But your pointer was quite insightful and now I have more ideas to play with. :P

Share this post


Link to post
Share on other sites

Nice one I got another idea from this...

Thanks dudes.


------------------------------------------------------"You are never a loser,until you quit trying"------------------------------------------------------

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0