Robot framework is generic keywords base testing framework. So can we use Ant task as a keyword in robot?
If yes what are the possible ways?
You can't use directly a Ant Task as a Robot keyword, but you can use Run Process keyword from the Process Library to launch the Ant command line you want to run:
*** test cases ***
my test
Run Process ant command line to launch
We can use "Run And Return Rc And Output" keyword from "OperatingSystem" Library
*** test cases ***
Test Ant
${RC} ${Output} Run And Return Rc And Output ant -f "antFile name"
where you need to set ANT_HOME and also set ANT in path variable
as
set PATH=%PATH%;%ANT_HOME%/bin
which will then run the ant task defined in ant file.
#{Flag}= Run And Return Rc And Output run.py
should Contain #{Flag} Camera Locked
The result will be saved in Flag variable and the next line will search for Camera Locked Text in output.
If you simply want to run just use Run And Return Rc
Related
I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program.
Currently when i type just "ant" in the command window where the build.xml file is listed it compiles and etc but then says
-do-jar-copylibs:
[copylibs] Nothing to copy.
[echo] To run this application from the command line without Ant, try:
[echo] java -jar "C:\Users\Eric\Documents\Word Documents\Java Test Code\NetbeansVersion\Cops\dist\Cops.jar"
I can run that command and it will run fine, but i want the program to execute by just typing ant.
The build.xml file - Pastebin
Build-impl.xml file - Pastebin
There are a couple "tasks" available in ant that you could use to accomplish this.
You can use either of these:
Java Task,
Exec Task
Those documentation pages provide examples as well. Before you go there though, you might want to start at the basic manual to get an idea of the structure of an ant build file to determine where and how you want to add this execution step in.
It feels a little "off" to me to have your build script executing the program, but I'm sure you've got a reason, so I might suggest adding a new target that does the build steps and then also runs this command to kick off the program. That way you've still got the option of running the build without running the program.
How to save current process running time in some text file using Ant, then read file and assign to Ant variable?
You can use ant exec task. There you can specify the executable ps and the necessary arguments (PID, options). You can check the argumengs here.
You specify outputproperty in ant exec task so the output will be redirected to this property.
Then you can put the value in a file using the echo task.
Following is the bat script code block on which i am working on:
ECHO off
IF NOT EXIST "%ANT_HOME%" (
SET ANT_HOME=%~dp0%build\apache-ant-1.8.2
SET ANT_BIN=%~dp0%build\apache-ant-1.8.2\bin
SET PATH | FIND "%ANT_HOME%;%ANT_BIN%"
)
cd "build\Run"
ant -q
cd ../..
echo "Program Terminated!"
exit
Now, my build.xml file is inside this build\Run folder so that i am first navigating to build/Run before running ant -q command (NOTE: I don't want to change this method of navigating).
The moment ant -q command is executed following things happen:
Set the environment variables as the condition.
Change directory to build\Run.
As my build.xml is inside the Run directory the ant -q command run correctly.
Ant executed correctly and not ant script terminates.
Now my current path will be build\Run ! correct <= Here i don't want this after ant is terminated, instead i want to come out from build\Run that's why i used cd../..
But the problem is I am not able to execute the commands after ant -q. This happens be the program control goes from BATCH => ANT.
Is there any way to execute my command after ant command from bat script itself ?
You may find that the ant being run is a batch file itself, in which case it simply chains to it (no return).
You should try this instead:
call ant -q
Calling a batch file (as opposed to chaining) will correctly return to the point after which you called it.
I want to include ANT, the JavaSDK and FlexSDK into my project directory. I need people in my company to be able to compile from source code.
I have a build.bat file which starts with :
ant blah/blah/blah
But what if I want to run ANT directly without the system environment variable? If I remove these from the system ant is not recognised.
I am a real newbie here, but I want to do something like this:
start "${basedir}\libs\ant\bin" ant -lib ${basedir}/libs/ant/lib/flexTasks.jar
pause
This is so that other people dont need to install a whole load of software... IT would all be contained in the folder.
Just set those environment variables in the same batchfile, i.e. something like :
set ANT_HOME=C:\ant182
set ANT_ARGS=-lib C:\antxtralibs
set JAVA_HOME=C:\jdk160_30
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin
:: default
ant -f %1
:: debug
:: ant -debug -f %1
I am using Apache Ant scripts for building a web application. I have written some targets in the build.xml file and the script is running fine. I remember using just "build" command to run ant build instead of "ant build". Can anyone tell me how is that achieved? I was a bit curious on this.
There's no built in "build" command. You could create a simple script file called "build" in the same directory that launched the ant build.
Create a text file with this as the contents:
ant build
In windows save this as a file called build.bat then you can just type build from the command line to start your build.
On unix or linux, save the file as build, then make it executable (with chmod +x build). You'll need to type ./build to get it to run.
I don't think there's a lot of value doing this to replace the simple case of ant build, but if you have to regularly run a build that has multiple targets, or need to pass in certain system variables then it could come in useful.
Maybe your are remembering typing "ant" instead of "ant build" in the past. This is possible to setup. You just need to set default attribute on the root project element in your Ant script to the name of the target you want invoked when an explicit target isn't specified.
For instance...
<project name="myproj" default="build">
...
</project>