This page is hosted for free by zzz.com.ua, if you are owner of this page, you can remove this message and gain access to many additional features by upgrading your hosting to PRO or VIP for just 32.50 UAH.
Do you want to support owner of this site? Click here and donate to his account some amount, he will be able to use it to pay for any of our services, including removing this ad.

Sauce labs, how to start?

Code example of simple test with usage of Sauce labs

public class Settings {
    public static final String USERNAME = "sanya_tolok";//your user name from https://saucelabs.com
    public static final String ACCESS_KEY = "7f92d543-541f-4214-a49d-24cdae1bb705";//access key taken from user settings inside your dashboard (https://saucelabs.com/beta/user-settings)
    public static final String URL = "http://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:80/wd/hub";
    public static void test_title() {
        {
            DesiredCapabilities caps = DesiredCapabilities.chrome();
            caps.setCapability("platform", "Windows XP");
            caps.setCapability("version", "43.0");
            WebDriver driver = null;
            try {
                driver = new RemoteWebDriver(new URL(URL), caps);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            driver.get("https://ddi-dev.com");//set your link
            System.out.println("title of page is: " + driver.getTitle());//thist test just print to console title of your page
            driver.quit();
        }
    }
    public static void waitInSeconds (int seconds)
    {
        try {
            Thread.sleep(1000*seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

}
}

Result

Selection_183

And if you don’t understood my comments, place where you could get your  ACCESS_KEY

Selection_181

TestNG Framework

images (2)imagesimages (1)

Talking about our requirement to introduce TestNG with WebDriver is that it provides an efficient and effective test result format that can in turn be shared with the stake holders to have a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to generate test reports. TestNG has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.

Both TestNG and JUnit belong to the same family of Unit Frameworks where TestNG is an extended version to JUnit and is more extensively used in the current testing era.

Features of TestNG

  • Support for annotations
  • Support for parameterization
  • Advance execution methodology that do not require test suites to be created
  • Support for Data Driven Testing using Dataproviders
  • Enables user to set execution priorities for the test methods
  • Supports threat safe environment when executing multiple threads
  • Readily supports integration with various tools and plug-ins like build tools (Ant, Maven etc.), Integrated Development Environment (Eclipse).
  • Facilitates user with effective means of Report Generation using ReportNG

TestNG versus JUnit

There are various advantages that make TestNG superior to JUnit. Some of them are:

  • Advance and easy annotations
  • Execution patterns can be set
  • Concurrent execution of test scripts
  • Test case dependencies can be set

Annotations are preceded by a “@” symbol in both TestNG and JUnit.So now let us get started with the installation and implementation part.

Creating a TestNG test class

  1. In the Project tool window, right click the directory where you want to create a new test class.
  2. Select New | Java Class from the context menu.
  3. In the Create New Class dialog, specify the class name and click OK.
  4. In the editor, write the code for your test class. Use the TestNG annotations where necessary. For example, you may want to annotate the whole class or individual methods:
    @Test ()
    public class NewClassForTesting {}
    @DataProvider public Object[][] data(){ return new String[][]{ new String[]{"data1"}, new String[]{"data2"} }; }
    @Test(dataProvider = "data") public void test(String d ){ Assert.assertEquals("First Line \n Second Line", "Third Line \n Fourth Line");}

    Here is a quick overview of the annotations available in TestNG for @Test along with attributes.

    @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

Bamboo CI, how it works

From what to start?

Start from installation of JAVA newest version (to use Bamboo like CI you will need at least java 8). Instruction with configuration(for Ubuntu) on the image below

Install-JAVA-8

Result:

Selection_123

BAMBOO Configuration

Step 1 : Download and install bamboo server from here bamboo

Step 2 : Set bamboo home directory(it must be outside installation directory, and name must be without special symbols), example in the image below

Selection_002

Step 3: Run server

Selection_004

Step 4: Open http://localhost:8085/ and if all correctly done before you will need to set licence(you can buy it or get some free, I am will be using free licence)

Selection_125

Step 5: After configuration of server you will need to create your first build plan

Step 6: Run your plan.

VIEW VIDEO