What’s new for me in 2016

Advertisements
Posted in Uncategorized | Leave a comment

Automation coverage Is it 100%?

What made me write this blogpost is question in 2016 which I had to face n no of times wrt more in automation coverage.How to build up the client confidence during transition or even during releases.

We were working for one of our finance client and at time we faced this question multiple time what is your test coverage and automation coverage ?During transition of this project to people who are still adopting agile way of working  we faced a question ,what report you can give us for audit? Ahh reporting we don’t do reporting in agile based project this was our first reaction with all jargons you need to trust your team and n no of counter arguments. But client need some reports for automation coverage to present before audit team which we never thought of.

This pushed me to go back and introspect our test coverage and how can we present to people who are not that close to code. After scratching couple of stickies these were the approaches which I decided to show them during transition :

  1. Make them comfortable with Test Pyramid.
  2. Educate them each and every test can’t be user flow.
  3. Give the basics of CI tool which your using , so they can see the reports by themselves whenever it is needed instead of searching stale reports in inbox.
  4.  QA+ProMa pairing helped us in our scenario, which helped to gain the trust and confidence of ProMa and get valuable inputs from ProMa (Product Manager) about test coverage.
  5. Walk through the regression pack if you have any where you have kept your scenario which are not automatable.

At the end of five week of transition the task which was not in my handover list made me learn to think that things needs to be communicated in a manner that whoever is involved in project should gain the confidence of test coverage ,not only from project and team trust perspective .

Now you know what you need to do when people ask for 100%test automation or test coverage.

With this I received the answer of most frequent asked question in 2016. Yes it is 100% at different levels 🙂

 

Posted in automation, test coverage | Leave a comment

Abstract keyword

Abstract Class : Must be Extended

Abstract Method : Must be Overridden

an abstract method has no body.

We can’t have an abstract method in a non abstract class

Abstract class can have both abstract and non abstract method
We must implement the abstract method means we should provide a body for method

Interface : 100% abstract class

A variable declared in an interface is always implicit final;

interface foo{

int x = new int

}

Posted in java | Tagged | Leave a comment

Method Overloading v/s Method Overridinng

Overriding : Same return type and no of arguments of method

  1. The argument list should be exactly the same as that of the overridden method.
  2. The return type should be the same or a subtype of the return type declared in the original overridden method in the superclass.
  3. The access level cannot be more restrictive than the overridden method’s access level. For example: if the superclass method is declared public then the overridding method in the sub class cannot be either private or protected.
  4. Instance methods can be overridden only if they are inherited by the subclass.
  5. A method declared final cannot be overridden.
  6. A method declared static cannot be overridden but can be re-declared.
  7. If a method cannot be inherited, then it cannot be overridden.
  8. A subclass within the same package as the instance’s superclass can override any superclass method that is not declared private or final.
  9. A subclass in a different package can only override the non-final methods declared public or protected.
  10. An overriding method can throw any uncheck exceptions, regardless of whether the overridden method throws exceptions or not. However the overriding method should not throw checked exceptions that are new or broader than the ones declared by the overridden method. The overriding method can throw narrower or fewer exceptions than the overridden method.
  11. Constructors cannot be overridden.
Posted in java | Leave a comment

Inheritance v/s Composition

IS -A : House is a Building
HAS-A : House has a Room.

Inheritance : Uni-Directional

Composition : Using instance variable that refer to other objects.

Posted in java | Leave a comment

JAVA keywords

Protected :  Only to classes in same package or sub classes of that class.

Abstract : Used to declare a class that can’t be instantiated or a method must be implemented by a non abstract modifier.

Extends : for inheritance

final : Impossible to extend a class , override a method and reinitialize a variable.

implements : used to indicate the interfaces that class will implement.

interface

native : Used to modify method declaration.

new :

static : Makes a method or variable belongs to a class as opposed to an instance. Method need not to be instantiated for it to called.

Posted in java | Leave a comment

Why static method cannot access non static variables

public class StaticTest {

    private int count=0;
    public static void main(String args[]) throws IOException {
        count++; //compiler error: non-static variable count cannot be referenced from a static context
    }
 }

Static variable in Java belongs to Class and its value remains same for all instance.
Static variable initialized when class is loaded into JVM on the other hand instance variable has different value for each instances and they get created when instance of an object is created either by using new() operator or using reflection like Class.newInstance().
 So if you try to access a non static variable without any instance compiler will complain because those variables are not yet created and they don’t have any existence until an instance is created and they are associated with any instance.

   So in my opinion only reason which make sense to disallow non static or instance variable inside static context is non existence of instance.

In summary since code in static context can be run even without creating any instance of class, 
it does not make sense asking value for an specific instance which is not yet created.



How to access non static variable inside static method or block

We can access any non static variable inside any static method or block by creating an instance of class in Java and using that instance to reference instance variable. This is the only legitimate way to access non static variable on static context.

public class StaticTest {
    private int count=0;
    public static void main(String args[]) throws IOException {
        StaticTest test = new StaticTest(); //accessing static variable by creating an instance of class
        test.count++;
    }

 }

Posted in java | Leave a comment