@BeforeSuite
@AfterSuite
@BeforeTest @AfterTest @BeforeGroups @AfterGroups @BeforeClass @AfterClass @BeforeMethod @AfterMethod |
Configuration information for a TestNG class:
@BeforeSuite: The annotated method will be run before all tests in this suite have run. @AfterSuite: The annotated method will be run after all tests in this suite have run. @BeforeTest: The annotated method will be run before any test method belonging to the classes inside the @AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the @BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked. @AfterGroups: The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked. @BeforeClass: The annotated method will be run before the first test method in the current class is invoked. @AfterClass: The annotated method will be run after all the test methods in the current class have been run. @BeforeMethod: The annotated method will be run before each test method. @AfterMethod: The annotated method will be run after each test method. | |
alwaysRun
|
For before methods (beforeSuite, beforeTest, beforeTestClass and beforeTestMethod, but not beforeGroups): If set to true, this configuration method will be run regardless of what groups it belongs to.
For after methods (afterSuite, afterClass, ...): If set to true, this configuration method will be run even if one or more methods invoked previously failed or was skipped. | |
dependsOnGroups
|
The list of groups this method depends on.
| |
dependsOnMethods
|
The list of methods this method depends on.
| |
enabled
|
Whether methods on this class/method are enabled.
| |
groups
|
The list of groups this class/method belongs to.
| |
inheritGroups
|
If true, this method will belong to groups specified in the @Test annotation at the class level.
| |
@DataProvider
|
Marks a method as supplying data for a test method. The annotated method must return an Object[][] where each Object[] can be assigned the parameter list of the test method. The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.
| |
name
|
The name of this data provider. If it's not supplied, the name of this data provider will automatically be set to the name of the method.
| |
parallel
|
If set to true, tests generated using this data provider are run in parallel. Default value is false.
| |
@Factory
|
Marks a method as a factory that returns objects that will be used by TestNG as Test classes. The method must return Object[].
| |
@Listeners
|
Defines listeners on a test class.
| |
value
|
An array of classes that extend org.testng.ITestNGListener.
| |
@Parameters
|
Describes how to pass parameters to a @Test method.
| |
value
|
The list of variables used to fill the parameters of this method.
| |
@Test
|
Marks a class or a method as part of the test.
| |
alwaysRun
|
If set to true, this test method will always be run even if it depends on a method that failed.
| |
dataProvider
|
The name of the data provider for this test method.
| |
dataProviderClass
|
The class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its base classes. If this attribute is specified, the data provider method needs to be static on the specified class.
| |
dependsOnGroups
|
The list of groups this method depends on.
| |
dependsOnMethods
|
The list of methods this method depends on.
| |
description
|
The description for this method.
| |
enabled
|
Whether methods on this class/method are enabled.
| |
expectedExceptions
|
The list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.
| |
groups
|
The list of groups this class/method belongs to.
| |
invocationCount
|
The number of times this method should be invoked.
| |
invocationTimeOut
|
The maximum number of milliseconds this test should take for the cumulated time of all the invocationcounts. This attribute will be ignored if invocationCount is not specified.
| |
priority
|
The priority for this test method. Lower priorities will be scheduled first.
| |
successPercentage
|
The percentage of success expected from this method
| |
singleThreaded
|
If set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="methods". This attribute can only be used at the class level and it will be ignored if used at the method level. Note: this attribute used to be called sequential (now deprecated).
| |
timeOut
|
The maximum number of milliseconds this test should take.
| |
threadPoolSize
|
The size of the thread pool for this method. The method will be invoked from multiple threads as specified by invocationCount.
Note: this attribute is ignored if invocationCount is not specified |
A blog dedicated to demystifying technology through powerful knowledge sharing. Explore bite-sized insights, real-world examples, and key takeaways on essential tech concepts — made simple, practical, and impactful for curious minds and seasoned professionals alike.
Tuesday, June 30, 2015
All TestNG annotations with attributes
Labels:
Automation,
Automation Framework,
Automation Testing,
Framework,
Framework development,
Test Automation,
Testing Framework
Thursday, June 25, 2015
Bitnami Jenkins Usage Steps
Jenkins, previously known as Hudson, is an open source continuous integration server. Built with Java, it provides over 400 plugins to support building and testing virtually any project. It supports SCM tools including CVS, Subversion, Git, Mercurial, Perforce and Clearcase, and can execute Apache Ant and Apache Maven based projects as well as arbitrary shell scripts and Windows batch commands. It also can monitor executions of remote tasks.
How to start/stop the servers?
Graphical tool
The native installers include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> Bitnami Stack -> Manager tool
Command line tool
If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

On Virtual Machines and Cloud images:
$ sudo /opt/bitnami/ctlscript.sh start
A native installer on Linux:
$ cd ~/application-version $ ./ctlscript.sh start

On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.
host:~ user$ cd /Applications/application-version host:~ user$ ./ctlscript.sh start
Where is JENKINS_HOME variable pointing to?
We define JENKINS_HOME in your installation directory in the apache-tomcat/conf/Catalina/localhost/jenkins.xml file. By default it is pointing to apps/jenkins/jenkins_home.
Notice that the installation directory is /opt/bitnami in the Bitnami virtual appliances and Bitnami Amazon Images.
How to start with Git and Jenkins?
Jenkins application is running as "tomcat" user so it is necessary to configure this user in case you want to access to a private repository. If you use a public repository is not necessary to configure the Tomcat user.
Configure Tomcat user to have access to the Git repository
Previous versions of Jenkins require to create the Tomcat user folder:
$ sudo mkdir /home/tomcat $ sudo mkdir /home/tomcat/.ssh
Then copy the private key to access to the repository into the "/home/tomcat/.ssh" folder:
$ sudo cp /path/to/id_rsa /home/tomcat/.ssh
And change the permissions
$ sudo chown -R tomcat:tomcat /home/tomcat
It is also necessary to save the hostname of your repository into the "known_hosts" file:
$ sudo su tomcat -c "/opt/bitnami/git/bin/git ls-remote -h git@YOUR_REPOSITORY.git HEAD" The authenticity of host 'ec2-xx-yy-zz.compute-1.amazonaws.com (xx.yy.zz)' can't be established. ECDSA key fingerprint is e5:xx:9d:yy:ff:89:55:47:aa:fd:b5:ee:0a:pp:6f:8d. Are you sure you want to continue connecting (yes/no)? yes
Configure Git repository in Jenkins
Before creating the first Job, it is necessary to configure the Git user and email that Jenkins will use to clone the repository. You can configure these options in "Manage Jenkins" -> "Configure System" -> "Git plugin" section
Then create a new Job in Jenkins and specify the Git repository.
And run the Build. If everything was properly configured, Jenkins will checkout the code from the Git repository.
How to upgrade Jenkins?
If you want to upgrade Jenkins keeping your data, you just need to download the latest jenkins.war file, copy it in your apache-tomcat/webapps directory and restart Tomcat. It is recommended to create a backup of the previous jenkins.war file. You may want to revert to the previous version if you find any issues after upgrading.
Upgrading only Jenkins
On Linux and OSX you can execute the following steps to perform the above (notice that the installation directory is /opt/bitnami in the Bitnami virtual appliances and Bitnami Amazon Images):
$ cd
## Stop the server
$ ./ctlscript.sh stop
## Copy your previous .war file in case you need to restore it
$ cp apache-tomcat/webapps/jenkins.war apps/jenkins/jenkins.war.bak
## Remove jenkins all files to force Tomcat to deploy the new jenkins.war file
$ rm -r apache-tomcat/webapps/jenkins
$ rm -r apache-tomcat/webapps/jenkins.war
$ rm -r apache-tomcat/work/Catalina/localhost/jenkins
## Donwload the new version of jenkins
$ mv jenkins.war apache-tomcat/webapps/
## Start the server
$ ./ctlscript.sh start
On Windows you can stop the servers from the Start Menu entry or using the graphical tool that you can find in your installation directory. Using the file explorer go to where you installed the Bitnami Jenkins Stack. Copy the jenkins.war file from the apache-tomcat/webapps directory to apps/jenkins. Download the latest jenkins.war file and copy it in apache-tomcat/webapps. Now just start the server from the Start Menu or using the graphical tool.
Upgrading all the components
Alternatively to the process above, you can download a new Bitnami Jenkins Stack. You can install it to a different location (remember to stop the previous install so there are no port conflicts) and point it to your previous JENKINS_HOME path by editing the file apache-tomcat/conf/Catalina/localhost/jenkins.xml.
If you are using a Bitnami virtual appliance or AMI you can start a new image with the latest jenkins version and move the content of /opt/bitnami/apps/jenkins/jenkins_home in your current installation to the new installation. Then restart the server.
How to enable SSL in Jenkins?
You can configure Apache Tomcat to enable SSL connections for accessing to the application using the HTTPS protocol. It is necessary to specify the Apache SSL certificate. If you do not have the cert you can create following these steps in the section below.
Check that you have the certificate file at "/installdir/apache-tomcat/conf/ssl/tomcat.cert.pem" and the certificate key file at "/installdir/apache-tomcat/conf/ssl/tomcat.key.pem".
To enable SSL you should uncomment the following line in the /installdir/apache-tomcat/conf/server.xml file:
8443
Then restart the Apache server and try to access at "https://localhost:8443".
How to create a SSL certificate for Jenkins?
You can find a detailed guide in the official Apache Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
Subscribe to:
Posts (Atom)