Renaming logs and reports in Robot Framework - robotframework

I know that it's not possible to add or remove sections in a Report for Robot Framework, but I wonder if it's possible to change the name of the Report from the Command Line.
So the reason for this is I have two Projects and they have the following folder structure
Project A
Testsuites
Keywords
Variables
And I have the exact same Structure for Project B. Project A and Project B are in the same directory.
When I run multiple tests the Log/Report that appears becomes "Testsuites" Test Log, since that's the name of the Folder where it is.
I want to be able to change the name on the command line so on the log it becomes "Project A Test Log" or "Project B" Test log. Would it be something like this?
pybot ./testsuites AS Project A

There are two ways:
You can give names of output files as pybot parameters:
pybot ./testsuites -o A.xml -l A.log -r A.html -x A.xunit.xml
It might be more convinient to save all files in their own directories:
pybot ./testsuites -d A_files

I think that you could mark tests from different projects with different tags and than you could run different tests
pybot -i projectA -l projectA_log.html -r projectA_report.html ./testssuites
or
pybot -i projectA -d projectA ./testssuites

pybot has a --name option. From the user guide:
-N, --name
Sets the name of the top-level test suite.
For slightly more information see http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-the-name

Related

External configuration of Project_Version in gpr file

With gnatpro 19.1, I'm trying to add gnathub to my project and am wondering how to set dynamically Project_Version as in:
package Dashboard is
for Project_Version use #git --describe --tags#; -- this needs to be updated.
end Dashboard;
I can't think of any simple way to do it.
A solution would be to use a Makefile that would configure a .gpr.in file but it seems contrived to change my whole buildchain just to add a version to the sonar config.
A simple, not automated solution, is to call the project with another switch:
gnathub -P Foo.gpr --plugins sonar-config,sonar-scanner\
--targs:sonar-scanner -Dsonar.projectVersion=$(git describe --tags)
But this is not really usable.
Similar question is to add the option -Dsonar.branch.name=$(git branch). AFAICT, the package Dashboard, as per the documentation has no Switch switch.
Is there any solution other than passing the extra arguments or forking gnatdashboard?
The best solution seems to reside in automating this configuration with a tool like Make.
For example, one can define the following Makefile:
# This target runs all the plugins listed
# in the section Dashboard.plugins of your project’s gpr
# sonar-config and sonar-scanner shall not be listed therein.
analyzes:
gnathub -P project
# This uses gnathub API to get the object dir where sonar-config file will be generated
OBJECT_DIR = $(shell gnathub -P project --exec object_dir.py 2>/dev/null | tail -n 1)
SONAR_PROPERTIES = $(OBJECT_DIR)/gnathub/sonar/sonar-project.properties
PROJECT_VERSION = $(shell git describe --tags)
BRANCH_NAME = $(shell git rev-parse --abbrev-ref HEAD)
# Uses gnathub to generate sonar properties file.
# Replaces the projectVersion and add branch name
# (notice that, on sonar, the branch name shall not be specified on your "master" branch)
$(SONAR_PROPERTIES): analyzes
gnathub -P project --plugins sonar-config --incremental
#sed -i "s/\(sonar.projectVersion = \).*/\1$(PROJECT_VERSION)/" $#
ifneq ($(BRANCH_NAME), master)
#echo "sonar.branch.name = $(BRANCH_NAME)" >> $#
endif
sonar: $(SONAR_PROPERTIES)
gnathub -P project --plugins sonar-scanner --incremental
.PHONY: sonar analyzes
Where object_dir.py is:
#!/usr/bin/env python
import GNAThub;
print (GNAThub.Project.object_dir());
Then:
$make sonar
Would run the analyzes and update them with the correct version and branch name (if necessary) to the SonarQube server.

How to save logs in robot framework like log.html ,report.html,output.xml with some particular name for ex log.html-> logxyz.html, abcreport.html?

I am trying to save the logs with the particular name in robot framework but not able to do that . Do we have a way to save the log name with the name as we want? If yes then how to do that ?
You have the following options to configure your output files:
-d, --outputdir <dir> Defines where to create output files.
-o, --output <file> Sets the path to the generated output file.
-l, --log <file Sets the path to the generated log file.
-r, --report <file> Sets the path to the generated report file.
So to change the name of the log file launch your tests like this:
robot --log logxyz --report abcreport my_robot.robot
You can check all command line options in Robot Framework User Guide to learn more.
With -T, --timestampoutputs you can add a timestamp to the name of the output files as well. An example name with --log and --timestampoutputs: my_log_file_name-20190103-102712.html.

How to change default output path in ROBOT Framework

How can I change default output path for a test suite in RIDE or by using CLI for ROBOT Framework?
You can use "-d" or "--outputdir" parameter to specify output path:
pybot -d outdir test.txt
You should use -d to create output files. The default is the directory where tests are run from and the given path is considered relative to that unless it is absolute.
Example : pybot -d C:\Work\Robot SampleTest.robot
All logs will be saved in C:\Work\Robot

PHPUnit testing individually in Symfony

I would like to run some unit Tests individually with PHPUnit, but I have certain classes separated from the Tests, since I am using the symfony framework, and I group the Tests and the Classes in different folders.
I would like to run the Tests individually like this:
php phpunit.phar MyTest.php
The problem is that the test file uses the classes from the controllers, and phpunit doesnt seem to be able to import the needed classes for the test.
This is not a problem to run all the tests together, thanks to phpunit.xml but when I want to run them individualy, its a problem.
How could I fix this?
You have to point phpunit where you have your phpunit.xml config file (because it must know the autoloader for example). If you have default symfony 2 structure it will be in app directory, so just run your test like that (I assume that you are in project root path):
phpunit -c app/ --filter="concreteTestPattern" src/Acme/DemoBundle/Tests/MyTest.php
edit:
Above will run all tests which names match to the pattern: /.*concreteTestPattern.*/
You would use the --filter argument in your PHPUnit command string. This will only run tests that match the pattern given. If you pass only the complete name of the test that you want run, phpunit should only run that test.
If you have a data provider associated with the test and only want to run one test case, you can also filter that by using --filter <testName>::<testcase name>
PHPUnit can be set to execute using a configuration file.
In our Symfony2 project this file is located at app/phpunit.xml.dist.
As this file is suffixed with .dist, you need to copy its contents into a file called app/phpunit.xml.
If you are using a VCS such as Git, you should add the new app/phpunit.xml file to the VCS ignore list.
You will also notice the configuration is specifying the bootstrap file located at app/bootstrap.php.cache. This file is used by PHPUnit to get the testing environment setup.
We can execute this test by running the following command from the root directory of the project. The -c option specifies that PHPUnit should load its configuration from the app directory.
$ phpunit -c app

XCode 'Run Script' step to create directory and copy file is failing

I have the following custom script step during my build:
mkdir -p "${CONTENTS_FOLDER_PATH}/Frameworks"
cp "${SRCROOT}/testing.1.dylib" "${CONTENTS_FOLDER_PATH}/Frameworks"
The script runs successfully, but when I check the bundle the Frameworks directory does not exist.
Should not not work as I expect? (Frameworks folder created with the testing.1.dylib in it).
Edit: Added screenshot of the runscript.
How about trying the following:
dst=${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks
mkdir -p "${dst}"
cp "..." "$dst"
(I found your example and adapted it as above to copy a dylib into the 'Frameworks' folder of my framework).

Resources