Friday, October 3, 2014

JIRA AUTOMATION USING REST API(JAVA)

1.     While working as a manual or automation tester we need to interact with JIRA many time, for bug reporting, for task creation etc, it take much time to do this again and again, to minimize this time, we can automate this process by interacting with JIRA using its REST API



1     1.    Create a java project in eclipse



1.       As a Prerequisite, we need some client libraries to access JIRA Rest API
Javax.ws.rs.jar
Jersey-bundle-1.6.jar

Jason-lib.jar




1.       Create Package & Class, Add following code

package testing;
import javax.naming.AuthenticationException;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.Base64;
import core.ValueSettings;
class Case1 {
   // Create a string for authorization(Passing username and password)
    static String auth = new String(Base64.encode(ValueSettings.userAuthentication()));

    // Url for creating an issue using REST API ----
    static String url = ValueSettings.getIssueURL()+"/TES";     // Project ID
    static String url11 = "http://localhost:8080/rest/api/2/issue";

     //JSON for creating an issue using REST API
        
             static String data = "{\"fields\"" +
                                                 ":{\"project\"" +
                                                                  ":{\"key\":\"TES\"}," +
                                                                 "\"description\": \"description|TESTING|B\"    ,"+   // Description
                                                                 "\"priority\": {\"name\": \"Major\"},"+
                                                                 "\"reporter\": {\"name\": \"testingworldnoida\"},"+
                                                                 "\"assignee\": {\"name\": \"testingworldnoida\"},"+
                                                                 "\"summary\":\"REST Test \",\"issuetype\":{\"name\":\"Task\"}}}";
             static String data2 = "{\"fields\"" +
                                                     ":{\"project\"" + 
                                                            ":{\"key\":\"TES\"}," +
                                         "\"summary\": \"something's wrong\","+
                                         "\"issuetype\": {\"name\": \"Task\"},"+
                                     //    "\"assignee\": {\"name\": \"testingworldnoida\"},"+
                                     //     "\"reporter\": {\"name\": \"testingworldnoida\"},"+
                                     //     "\"priority\": {\"name\": \"Major\"},"+
                                       
                                         "\"description\": \"description\"}" ;
             
             //url for retrieving an issue using REST API ---- R of CRUD
              static String url1 = "http://localhost:8080/rest/api/2/issue/TJ-1";
            //url for updating an issue using REST API ---- U of CRUD
             static String url2 = "http://localhost:8080/rest/api/2/issue/TJ-1";
             
               /*
                * JSON data to be updated for an issue using RESP API               
                *
                * */
       
             static String data1 = "{\"fields\":{\"assignee\":{\"name\":\"vinodh\"}}}";
           
                  //  String data2 = "{fields:{summary:Demo Test}}"
               /*
                * url for deleting an issue using RESP API ---- D of CRUD
                *
                * */
              static String url3 = "http://localhost:8080/rest/api/2/issue/TJ-1";
             /*
                * HTTP POST method is used to create the issue
                *
                * */
                public static String invokePostMethod(String auth, String url, String data) throws AuthenticationException, ClientHandlerException {
                   Client client = Client.create();
                   System.out.println(url);
                   WebResource webResource = client.resource(url);
                 
                   ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").post(ClientResponse.class, data);
                   int statusCode = response.getStatus();
                   System.out.println(statusCode);
                   if (statusCode == 401) {
                       throw new AuthenticationException("Invalid Username or Password");
                   }
                   return "issue successfully created"; 
               }
                         
               /*
                * HTTP GET method is used to get the issue
                *
                * */
               private static String invokeGetMethod(String auth, String url) throws AuthenticationException, ClientHandlerException {
                   Client client = Client.create();
                   WebResource webResource = client.resource(url);
                   ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").get(ClientResponse.class);
                   int statusCode = response.getStatus();
                   System.out.println(statusCode);
                   if (statusCode == 401) {
                       throw new AuthenticationException("Invalid Username or Password");
                   }
                   return response.getEntity(String.class);
               }
           
               /*
                * HTTP PUT method is used to update the issue
                *
                * */
            private static String invokePutMethod(String auth, String url, String data1) throws AuthenticationException, ClientHandlerException {
                                   Client client = Client.create();
                                   WebResource webResource = client.resource(url);
                                   ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").put(ClientResponse.class, data1);
                                   int statusCode = response.getStatus();
                                   if (statusCode == 401) {
                                       throw new AuthenticationException("Invalid Username or Password");
                                   }
                                   return "success";
                               }            
              /*
                * HTTP DELETE method is used to delete the issue
                *
                * */
              private static String invokeDeleteMethod(String auth, String url) throws AuthenticationException, ClientHandlerException {
                   Client client = Client.create();
                   WebResource webResource = client.resource(url);
                   ClientResponse response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").delete(ClientResponse.class);
                   int statusCode = response.getStatus();
                   if (statusCode == 401) {
                       throw new AuthenticationException("Invalid Username or Password");
                   }
                   return "successfully deleted";
               }            
       
              public static void main(String[] args) throws Exception {
                              /*
                                * 1. Creating an JIRA issue in project with key TJ using REST API
                                *
                                */
                            
                              System.out.println(invokePostMethod(auth, url11, data));
                                                  
                                /*
                                * 2. Getting details of an JIRA issue in project with issue no TJ-1 using REST API
                                */
                              
                              String resp=invokeGetMethod(auth, url1);                       
                             
                              JSONObject jo=(JSONObject)JSONSerializer.toJSON(resp);
                            
                               JSONObject sum=jo.getJSONObject("fields");
                            
                               System.out.println(sum.getString("summary"));
                                                          
                               /*
                                * 3. Updating details of an JIRA issue in project with issue no TJ-1 using REST API
                              */
                         
                               System.out.println(invokePutMethod(auth, url2, data1));
                                                         
                               /*
                                * 4. Deleting an JIRA issue in project with issue no TJ-1 using REST API
                                */                          
                              
                               System.out.println(invokeDeleteMethod(auth, url3));
                   }
             
             
            
}

 Run this code, go to  JIRA and Verify



Here we will find Task is created 



















Sunday, September 21, 2014

Different meetings in Agile


What are the different meetings in Agile? What is purpose of Release Planning, Sprint Planning meetings, Scrum Meeting, Sprint Review Meeting, Retrospection?

Release Planning

  In this release plan is prepared, which include list of features that needs to be delivered, release date of software into Production, number of iterations/sprints for that release etc.

Sprint Planning

  In this product Owner presents the set of features he would like and the team asks questions to understand the requirements in sufficient detail to enable them to commit to delivering the listed features in sprint.

Daily Scrum Meeting

   Daily Scrum Meeting is for answering the following 3 questions:

·         What have you done since yesterday’s meeting?

·         What are you going to get done today?

·         What obstacles do you need to be removed?

Sprint Review

  It is demonstration of the new features the team has completed during the sprint; it is used to gather early feedback.

 Sprint Retrospection

   It follows immediately after the sprint review. It is focused on the process, the way in which the Scrum team is working together, including their technical skills and the software development practices and tools they are using.

In this meeting team discuss on following points:

·         What went wrong?

·         What went well?

·         What can be improved?

Wednesday, September 3, 2014

Agile Methodologies for Software Development

The various agile methodologies share much of the same philosophy, as well as many of the same characteristics and practices. But from an implementation standpoint, each has its own recipe of practices, terminology, and tactics. Here we have summarized a few of the main agile software development methodology contenders:

Scrum

Scrum is a lightweight agile project management framework with broad applicability for managing and controlling iterative and incremental projects of all types. Ken Schwaber, Mike Beedle, Jeff Sutherland and others have contributed significantly to the evolution of Scrum over the last decade. Scrum has garnered increasing popularity in the agile software development community due to its simplicity, proven productivity, and ability to act as a wrapper for various engineering practices promoted by other agile methodologies.
With Scrum methodology, the "Product Owner" works closely with the team to identify and prioritize system functionality in form of a "Product Backlog". The Product Backlog consists of features, bug fixes, non-functional requirements, etc. - whatever needs to be done in order to successfully deliver a working software system. With priorities driven by the Product Owner, cross-functional teams estimate and sign-up to deliver "potentially shippable increments" of software during successive Sprints, typically lasting 30 days. Once a Sprint's Product Backlog is committed, no additional functionality can be added to the Sprint except by the team. Once a Sprint has been delivered, the Product Backlog is analyzed and reprioritized, if necessary, and the next set of functionality is selected for the next Sprint.
Scrum methodology has been proven to scale to multiple teams across very large organizations with 800+ people. See how VersionOne supports Scrum Sprint Planning by making it easier to manage your Product Backlog.

Lean and Kanban Software Development

Lean Software Development is an iterative agile methodology originally developed by Mary and Tom Poppendieck. Lean Software Development owes much of its principles and practices to the Lean Enterprise movement, and the practices of companies like Toyota. Lean Software Development focuses the team on delivering Value to the customer, and on the efficiency of the "Value Stream," the mechanisms that deliver that Value. The main principles of Lean methodology include:
  • Eliminating Waste
  • Amplifying Learning
  • Deciding as Late as Possible
  • Delivering as Fast as Possible
  • Empowering the Team
  • Building Integrity In
  • Seeing the Whole
Lean methodology eliminates waste through such practices as selecting only the truly valuable features for a system, prioritizing those selected, and delivering them in small batches. It emphasizes the speed and efficiency of development workflow, and relies on rapid and reliable feedback between programmers and customers. Lean uses the idea of work product being "pulled" via customer request. It focuses decision-making authority and ability on individuals and small teams, since research shows this to be faster and more efficient than hierarchical flow of control. Lean also concentrates on the efficiency of the use of team resources, trying to ensure that everyone is productive as much of the time as possible. It concentrates on concurrent work and the fewest possible intra-team workflow dependencies. Lean also strongly recommends that automated unit tests be written at the same time the code is written.
The Kanban Method is used by organizations to manage the creation of products with an emphasis on continual delivery while not overburdening the development team. Like Scrum, Kanban is a process designed to help teams work together more effectively.
Kanban is based on 3 basic principles:
  • Visualize what you do today (workflow): seeing all the items in context of each other can be very informative
  • Limit the amount of work in progress (WIP): this helps balance the flow-based approach so teams don 't start and commit to too much work at once
  • Enhance flow: when something is finished, the next highest thing from the backlog is pulled into play
Kanban promotes continuous collaboration and encourages active, ongoing learning and improving by defining the best possible team workflow. See how VersionOne supports Kanban software development.

Extreme Programming (XP)

XP, originally described by Kent Beck, has emerged as one of the most popular and controversial agile methodologies. XP is a disciplined approach to delivering high-quality software quickly and continuously. It promotes high customer involvement, rapid feedback loops, continuous testing, continuous planning, and close teamwork to deliver working software at very frequent intervals, typically every 1-3 weeks.
The original XP recipe is based on four simple values – simplicity, communication, feedback, and courage – and twelve supporting practices:
  • Planning Game
  • Small Releases
  • Customer Acceptance Tests
  • Simple Design
  • Pair Programming
  • Test-Driven Development
  • Refactoring
  • Continuous Integration
  • Collective Code Ownership
  • Coding Standards
  • Metaphor
  • Sustainable Pace

Preventive Testing & Reactive Testing

Preventive Testing
Testing which is done in parallel to software development process is called preventive testing. Functional testing is the example of Preventive testing in which we started to develop test cases in parallel to development process.

Reactive Testing :
Testing which starts when application is completely developed is called Reactive testing. Exploratory testing and Ac-hoc testing is the example of Reactive testing