Monday, 16 November 2020

Multiple Inheritance

 package practice.test;


interface Ones {

void print_test();

}

interface Twos{

public void print_test1();

}


interface Three extends Ones,Twos{

void print_test();

}

class child implements Three

{

@Override

public void print_test() {

System.out.println("Test overides - Test Methods");

}

public void print_test1() {

System.out.println("Inside Test1");

}

}


 class Main_01

{

public static void main(String[] arg) {

child c=new child();

c.print_test();

c.print_test1();

c.print_test();

}

}

Sunday, 15 November 2020

Inheritance concept

 package practice.test;


class One {

public void print_greek() {

System.out.println("Geeks");

}

}


class Two extends One{

public void print_for() {

System.out.println("For");

}

}


class Main

{

public static void main(String[] args) {

Two t=new Two();

t.print_greek();

t.print_for();

t.print_greek();

}

}

Inheritance concept

 Implementation of Inheritence


package practice.test;


public class Bicycle {

public int gear;

public int speed;

// Constructor

public Bicycle(int gear,int speed) {

this.gear=gear;

this.speed=speed;

}

// the Bycycle class has three methods

public void applyBreak(int decrement) {

speed-=decrement;

}

public void speedUp(int increment) {

speed+=increment;

}

public String toString() {

return ("No of gears are "+gear+"\n"+"speed of bicycle is"+speed);

}

}

// derived class

class MountainBike extends Bicycle

{

public int seatHeight;

public MountainBike(int gear,int speed,int seatHeight) {

super(gear,speed);

this.seatHeight=seatHeight;

}

// method

public void setSeatHeight(int newValue) {

seatHeight=newValue;

}

@Override

public String toString() {

return (super.toString() + "\n height is \t"+seatHeight);

}

}




package practice.test;


public class Tests {


public static void main(String[] args) {

// TODO Auto-generated method stub

MountainBike mBike=new MountainBike(3,100, 25);

System.out.println(mBike.toString());

}


}



-- Output

No of gears are 3

speed of bicycle is100

 height is 25

Implementation of Interface

 Interface Implementation an Interface defined in class

example here under
package practice.test;

public class IntefaceInsideClass {
interface Viechle{
public int getNoOfWheels();
}
}
Implementation of Interface
package practice.test;

public class Bus implements IntefaceInsideClass.Viechle{
public int getNoOfWheels() {
return 6;
}
}

package practice.test;

public class Cars implements IntefaceInsideClass.Viechle{
public int getNoOfWheels() {
return 4;
}

}

package practice.test;

public class Bikes implements IntefaceInsideClass.Viechle{
public int getNoOfWheels() {
return 2;
}

}


Finaly call for executions
package practice.test;

public class TestClass1 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Bus b = new Bus();
System.out.println("No of Wheels for bus\t"+b.getNoOfWheels());
Cars c=new Cars();
System.out.println("No of Wheels for cars\t"+c.getNoOfWheels());
Bikes b1=new Bikes();
System.out.println("No of Wheels for bike\t"+b1.getNoOfWheels());

}

}

Output
-------------
No of Wheels for bus 6
No of Wheels for cars 4
No of Wheels for bike 2

Sunday, 8 November 2020

TestNG Selenium Priority and dependsOnMethod

 package TestNG;


import org.testng.annotations.Test;


public class LearningTestPriority {

@Test

public void Login() {

System.out.println("Login to the application");

}

@Test(dependsOnMethods= {"Login"},priority=-1)

public void Navigation() {

System.out.println("Navigate the details page");

}

@Test(dependsOnMethods= {"Navigation"})

public void Logout() {

System.out.println("Logout from the Session");

}

@Test(dependsOnMethods= {"Login"})

public void HomePage() {

System.out.println("Going to Home Page");

}

}

--------------------
Output
-------------------
[RemoteTestNG] detected TestNG version 7.3.0
Login to the application
Navigate the details page
Going to Home Page
Logout from the Session
PASSED: Login
PASSED: Navigation
PASSED: HomePage
PASSED: Logout

===============================================
    Default test
    Tests run: 4, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 4, Passes: 4, Failures: 0, Skips: 0
===============================================

#kazacademy #kazonline

TestNG Selenium Priority

 package TestNG;


import org.testng.annotations.Test;


public class LearmingTestNGPriority {

@Test(priority=1)

public void Login() {

System.out.println("Login Test");

}

@Test(priority=3)

public void Logout() {

System.out.println("Logout Test");

}

@Test(priority=2)

public void Navigate() {

System.out.println("Navigation Test");

}

@Test(priority=-1)

public void WebDriverLoad() {

System.out.println("Web Driver Load First");

}

}

---
Output
------

[RemoteTestNG] detected TestNG version 7.3.0
Web Driver Load First
Login Test
Navigation Test
Logout Test
PASSED: WebDriverLoad
PASSED: Login
PASSED: Navigate
PASSED: Logout

===============================================
    Default test
    Tests run: 4, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 4, Passes: 4, Failures: 0, Skips: 0
===============================================

#kazacademy #kazonline

Selenium TestNG example

 package TestNG;


import org.testng.Assert;

import org.testng.SkipException;

import org.testng.annotations.*;

import org.testng.asserts.*;

// Pass Fail Skip Test Example

public class FailPassSkipTest {

@Test

public void Test1() {

System.out.println("Test - 1");

//Assert.assertEquals("Test1", "Shahnawaz");

//Assert.assertEquals(1, 2);

//Assert.assertTrue(4<1);

Assert.assertFalse(4<1);

}

@Test

public void Test2() {

System.out.println("Test - 2");

throw new SkipException("Test 2 is not configured");

}

@Test

public void Test3() {

System.out.println("Test - 3");

}


}