Skip to content

Instantly share code, notes, and snippets.

public class MainClass {
public static void main(String args[]) {
BmwCar bmw = new BmwCar();
bmw.getPrice();
bmw.changeGear(4);
bmw.speedUp(60);
}
}
public class HondaCar {
int price = 100000;
public void getPrice(int price) {
System.out.println("The price of the Honda car is:" + price);
}
}
public class AudiCar {
int price = 500000;
public void getPrice(int price) {
System.out.println("The price of the car is:" + price);
}
}
public class BmwCar extends Car {
int price = 100000;
public void getPrice(int price) {
System.out.println("The price of the car is:" + price);
}
}
public class Car {
//Below 2 fields are states
int gear = 0;
int speed = 0;
//All below methods are behaviors
void changeGear(int newValue) {
System.out.println("Changing the gear to:" + newValue);
}
<html>
<body>
<form action="/my-handling-form-page" method="post">
<div>
<label for="name">Name:</label>
<input type="text" id="name" />
</div>
<div>
<label for="mail">E-mail:</label>
<input type="email" id="mail" />
[TestNG] Running:
C:\Users\username\AppData\Local\Temp\testng-eclipse-1346797963\testng-customsuite.xml
This is a @BeforeSuite annotated method and this is executed at the beginning of the test suite execution
This is a @BeforeClass annotated method and this is executed at the beginning of the test class execution
This is a @BeforeMethod annotated method and this is executed at the beginning of the each test method
This is a @test annotated method and your testing will be done here
This is a @AfterMethod annotated method and this is executed at the end of the each test method
This is a @BeforeMethod annotated method and this is executed at the beginning of the each test method
This is a @test annotated method and your testing will be done here
package com.annotations.example;
import org.testng.annotations.*;
public class TestNgAnnotations {
@BeforeSuite
public void beforeSuite() {
System.out.println("This is a @BeforeSuite annotated method and this is executed at the beginning of the test suite execution");
}
package com.selenium.webdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class WebdriverDemo
{
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class DriverFactory
{
private DriverFactory()
{
//Do-nothing..Do not allow to initialize this class from outside
}