HOW TO MANAGE TEST CASES AND BUGS USING JIRA

HOW TO MANAGE TEST CASES AND BUGS USING JIRA

My determination of writing this blog is to describe how we can use JIRA as a TC (Test cases) and bug management with the help of add-on JIRA Cli. Also, this document will help in analyzing the benefits & drawbacks of using JIRA as a test case management.

Previously, I had to depend on an Excel spreadsheet for logging test cases and JIRA for tracking bugs in my project. I needed a tool by which we can accomplish both test cases and bugs with using a single tool. Now I am using JIRA for Test cases and bug management in spite of some constraints as outlined in the later part of this blog.

Modification in JIRA

Modifications are required to use existing flow of JIRA as a Test Case  management with the help of a JIRA administrator. Below are the steps to modify the existing JIRA workflow:

  • Create/Add new Issue type
  • Create/Add new Status
  • JIRA default workflow
  • Test case work flow after modification
  • Status in Test case workflow

Here are additional detail explaining each of the steps below:

How to create issue type?

Add a new issue type in existing flow and name it “Test case.” This should be a top- level (standard) task (for this go to Administration > Issues > Issues Types and use  Add Issue Type option).

How to create status?

Add new status (for this go to Administration > Status > Status Types and use Add    Status Type option)

JIRA default workflow

JIRA workflow is the set of status and transitions through which an issue goes during its lifecycle.

JIRA default workflow 

Test case work flow after modification

After modification with the help of JIRA administrator below is the Test case workflow with different status:

Test case work flow  

Status in Test case workflow:

TC awaiting review: Default status when a Test Case is created and awaiting for Review from the QA lead.

TC Template: An approved TC that has not yet been scheduled yet.

TC-Ready to Run: TC that has been scheduled.

In Progress: TC that has been in-progress state

TC-Failed: After execution when TC fail status update to TC-Failed

TC-Passed: After execution when TC Pass status update to TC-Passed

TC-Invalid: A test that has become obsolete or cannot be run

Closed: This is the final status of the TC.

About JIRA CLI

One of the major challenge was how to import the TCs in JIRA because designing test cases one by one in JIRA was time consuming. A tool was needed by which I can upload the TC in JIRA from file (.csv, Excel, etc.). Finally, I found Add-on JIRA CLI (free tool ~Till version 2.6.0) to import the Test case’s from .csv

How to import Test case using JIRA CLI?

-Download jira-cli-2.6.0 from this link

-Save the Test cases file with name import.xls and convert into .csv format then copy import.Csv file under downloaded folder (jira-cli-2.6.0) .csv format given below

JIRA
~In above import.csv file Description column consist  merge data of (Prerequisites, Steps, and Expected Results)

-Under downloaded folder (jira-cli-2.6.0) there is a file with name import.properties

-Map column name for which we want to import the data in the properties file

field.Type = Type

field.Component = Components

field.Project = Project

field.Objective = Summary

field.Description = Description

File (~import.properties file format as seen above)

-Run the following single line command in command prompt

c://Jira-cli-3.8.0>jira.bat –server <URL of JIRA> -user kailash.pathak – password “xxxxxxx” –action runFromCsv –file import.csv –propertyFile import. Properties –common “–project SSPQA”               – continue

(~Here “SSPQA” Is Project Key)

-Test case data is imported in JIRA against the particular components successfully

Process for Test case creation and allocation in JIRA

Below are the steps for test case creation and allocation in JIRA:

Test Case creation steps:

  • Create a new project with the help of JIRA administrator.
  • Create sprint Task, sub task for QA e.g. Design Test case and Execute Test case of particular module    
  • Create Components against the Project with the help of JIRA administrator
  • Create Test Case In Excel
  • Convert TC in .csv file with giving name as import.csv (its mandatory csv with this  name) for to import in JIRA. csv file format attached above
  • Upload .csv into JIRA using JIRA CLI using the (above mentioned steps)

Create Test Case in excel sheet in the format which is acceptable by JIRA CLI (see below for example)

JIRA 

Test Case Allocation steps :

We can allocate Test Cases for execution using bulk change functionality. During the bulk change we can assign the user name to the Test Cases.

First search the TCs then assign user name in bulk by clicking on Assign to me link see below screen shot for more detail

JIRA-KP-3 

 

JIRA-KP-4
Test Case Execution

Once the TCs are allocated next step is to execute the Test Cases in JIRA with updating their status with Pass, Fail etc.

Prerequisites:

  • We are executing TC in three browsers (Chrome, IE, and FireFox)
  • We are executing each of TC in two cycles (Cycle 1, Cycle 2)

After uploading and allocating the test cases next step is to execute the test cases. Follow these steps to execute it:

  • Bring all Test cases we want to execute in “IN PROGRESS” state using Bulk change functionality
  • Execute TCs one by one

In case of Test case FAIL

  • In case of a FAIL a New Transition comments screen (See screen shot below) open
  • Enter actual result.
  • Enter Sprint<Sprint Number>-Cycle< Test Cycle No. >-<Browser Name> <Fail>

E.g. Sprint26-Cycle1-IE-Fail as Comment

  • Click on the Fail button
  • Particular test case is Fail
  • Report bug for Fail Test Case
  • Link Fail Test Case with Bug Number (Explain in next point)

JIRA-KP-5  

Linking of Fail Test case with Bug ID

To link the test case with Bug ID Open Particular Failed TC and Click on “Link” from menu following screen open to link the Test Case with Bug ID after clicking on link button Fail TC link with the Bug ID

JIRA-KP-6 

In case of Test case PASS

If Test Case Pass in first time or in second cycle in that case update the comments with Pass status and with respective Cycle Below the screenshot when TC pass in second cycle

JIRA-KP-7 

*Note:

Entered above comments help us to pull out the report.

In case of Test case INVALID

In case of invalid test case that has become obsolete or cannot be run. We will update the status as shown below:

*Note:

Same transition screen open to enter comments in case of other status (Closed, TC-Template, TC-Ready to Run etc.)

Report in JIRA of Test Cases

We can generate execution report using different criteria (We can use the entered comments during execution of TC as search criteria).

Search Criteria:

Sprint Wise Report

    1. Complete Sprint wise report (Sprint26-*)

    Example:

Enter Sprint26-* in the Comment window after selecting Project, Components as shown in the screen below:

JIRA-KP-10 

End Result:

This search criteria displays all executed TCs (Pass, Fail, Invalid etc.)  with a consolidated list as shown below:

We can convert this report data (in Two Dimensional and Pie Chart illustrations as well)

See two dimensional and pie chart report for the above documented criteria

JIRA-KP-11 

*Note:

For each of the below mentioned search criteria we can create a similar report

2. Sprint with cycle wise report Sprint26-Cycle1-*

End Result:

This search criteria display all executed TC of Cycle1

JIRA-KP-12We can convert this report data in (Two Dimensional and Pie Chart

3.Sprint with Cycle and Browser wise (Firefox, IE, Chrome) report

  • Search by criteria Sprint26-Cycle1-FF-*
  • Search by criteria Sprint26-Cycle1-IE-*
  • Search by criteria Sprint26-Cycle1-Chrome-*

End Result:

This search criteria displays all executed TC of Cycle1 for different browser

We can convert this report data in (Two Dimensional and Pie Chart)

4. Sprint with (Cycle, Browser and Test case Pass) wise report

Search by criteria Sprint26-Cycle1-IE-Pass

End Result:

This search criteria display all Passed TC of Cycle1 for Browser IE

We can convert this report data in (Two Dimensional and Pie Chart)

5. Sprint with (Cycle, Browser and Test case Fail) wise report

Search by criteria Sprint26-Cycle1-IE-Fail

End Result:

This search criteria display all Failed TC of Cycle1 for Browser IE

We can convert this report data in (Two Dimensional and Pie Chart)

*Note:

Similarly we can generate report for Cycle2 #

JIRA – Pros

  • Bulk clone is possible
  • Possibility to update the status of multiple test cases at once
  • Custom searches can be saved as filters and shared through products/users
  • Test plan can be easily create in JIRA by putting together all test cases to be executed in that iteration (Sprint)
  • Easily linking between Test Cases and Bugs
  • Provides an advanced search mechanism and a way to create custom search queries

JIRA – Cons:

  • The “look and feel” is the same as for bugs not as for a normal test case management tool (like Test Link or Quality Center)
  • Initial set up is bit time consuming but once design user can easily manage the Test Cases

 Conclusion

  • With this blog, we have understood how we can use JIRA as a single tool to create, execute Test Cases and bug management.
  • We have also given a brief overview of add-on JIRA Cli and its uses when it comes to importing the test case in JIRA.
Advertisements

Creating MAC OS X Lion Login and Desktop using Css3

This post is taken from http://www.alessioatzeni.com/blog/mac-os-x-lion-with-css3/

Alessio Atzeni wanted to create with only use of CSS3 the boot, the login page and finally the desktop of the Mac OS X Lion.

This is the first release and as you will see not everything is fully functional and at least as regards the desktop. In the next release Alessio Atzeni will implement new icons and new features while we examine what we have today.
Boot

This is simply the Mac OS X Lion boot. This section is simply composed by a CSS3 keyframes animation.
It has a logo (created in Photoshop) and a simple loader (fake loading). After the animation, dissolves the section to show the login section.

mac-boot
Login

This section mainly consists of a clock, two images (logos and avatars user name), two backgrounds and a password input field.
Alessio Atzeni used javascript only for the clock, create a fake login and when the password is valid Alessio Atzeni added some class to fix the desktop section and remove permanently the section login animation.

Thanks to the :target pseudo-class can be passed from one section to another. Regarding the rest is all CSS 3, such as hide/show the input field when you click on the avatar, same goes for the appearance of the tooltip when you click on the input field.

The animation of password error is connected via javascript but the animation is created using CSS3. The pseudo-class target has its limits and then to fix those small weaknesses, once you enter your password, javascript sets the desktop as the main section.

mac-login
Desktop

Finally here we have in our desktop. As mentioned previously this is only the first version, and consequently still missing several features that Alessio Atzeni will implement in the next release. Alessio Atzeni use javascript only for the clock and the jQuery UI Draggable library to have a draggable windows.

For the rest is all CSS3 excluding the background image and icons.

mac-dock
About this Project

Here Alessio Atzeni will list what he used for this project.
Modern Browser Supported

To see this experiment you will need a browser that supports CSS3 Keyframes Animations, so the choice is Firefox, Safari, or Chrome.
HTML5 and CSS3

For this project he used HTML5 and the unique capacity of CSS3.
Javascript

The use of JavaScript is for the clock, and to add a fix to the section desktop once you get the validation.
Draggable Window

Alessio Atzeni used this library jQuery UI Draggable.
Images and other decoration

Finally he used images for logos, user-avatar, spinner loading, cursors, background images, icons and window buttons.
Conclusion and Next Release

At the end of this experiment he realized the potential and limitations of CSS3, but thanks to the use of javascript (although to a limited) you can really get something unique.

Regarding the next release he plan to add the dock, delete and appears the windows if you click on a link on the menu only through the use of CSS. Optimize the code for better performance.

Alessio Atzeni hope that this experiment can be useful, and please you in your study, if you have any questions please do not hesitate to write.

Thank you all for your support.

Install Red5 on Windows 7 (64-bit)

Install Red5 on Windows 7 (64-bit)

We will install Red5-0.9.1 on Windows 7 (64-bit). We will also install some required features for further development and use.
Those are :
Java Development Kit v.1.6
apache-ant v.1.7
eclipse-galilleo-SR1-win32

1. Download and Install the 32-bit version of the JDK 6 (jdk-6u29-windows-i586.exe).
Copy the ….\Java\jdk1.6.0_29\bin\java.exe  and paste it in …..C:\Windows\SysWOW64.
We need this specific java version because Red5 version 0.9 is compatible with Java Version 1.6 & eclipse galileo is compatible with the 32-bit version of JDK.

2. Download apache-ant version 1.7(apache-ant-1.7.1-bin.zip) from http://archive.apache.org/dist/ant/binaries/.
NOT version 1.8 because it creates some kind of problem with the javac.
So download the apache-ant-1.7.1-bin.zip file and extract it on your Hard Disk. I put it in C:/Program Files (x86)/Java to keep it all together.
Rename the extracted folder to Ant.

3. Download and Install Red5-0.9.1 for windows, from http://trac.red5.org/wiki/0_9_1 .
Change the install directory to C:/Red5.
Enter IP Adress : 127.0.0.1 (for local install).
Enter Port Number : 5080.

4. Download eclipse-galileo-SR1.win32.zip from http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/galileosr1 .
Extract the folder eclipse somewhere on your Hard Disk. I put it in C:\eclipse.
No need to install, to run just double click the eclipse.exe.

5. IMPORTANT: Enviromental Variables
To set the Enviromental Variables, go to control panel -> system -> Advanced system settings -> Enviroment Variables.
Select Path->edit and add the ANT path. example : …..;C:\Program Files (x86)\Java\Ant\bin;….
Select Path->edit and add the JDK path. example : …;C:\Program Files (x86)\Java\jdk1.6.0_29\bin;..
Select New and add name: ANT_HOME . value the Ant path for example C:\Program Files (x86)\Java\Ant
Select New and add name: JAVA_HOME , value: the jdk path for example C:\Program Files (x86)\Java\jdk1.6.0_29
Select New and add name: JAVA_VERSION , value: 1.6
Select New and add name: RED5_HOME , value: C:\Red5

6. To start Red5 run red5.bat and to stop run red5-shutdown.bat. It’s better to use the red5-shutdown.bat to close it, to avoid malfunction.
On your browser type “localhost:5080” to start using Red5.
Choose “Install a ready made application”. Install everything except audiotranscoder and videotranscoder. They require to install xuggle first. (but xuggle is not compatible with windows 7 64-bit, so we won’t be able to install any application that requires xuggle).
Choose “Launch a demo to use an installed application.

What is and how to install Red5 in Windows

What is and how to install Red5 in Windows?

I started looking at Red5 these days and decided to write a post about it.

What is Red5?

Many years ago Adobe (legacy Macromedia) created a software called Flash Communication Server. This was a media server that allowed users to transfer real-time data, audio and video to create multi-user applications. Adobe changed its name to Flash Media Server or FMS. To send data it uses a protocol called RTMP (Real Time Messaging Protocol) and a data format known as AMF (ActionScript Message Format).

The license is pretty expensive. The cheapest one is about 999 USD and the most expensive one 4500 USD (or more) and not so many people and/or small companies have this amount of money for a single software.

A cheaper alternative is SmartFox Server that is very similar to Flash Media Server and manages prices between 500 a 2000 euros. This server is better for MMO games and supports connections not only from Flash but also from Unity, Silverlight, .net, Java, Android and iPhone. You can also buy an isometric game engine called OpenSpace by paying 2200 euros more. It keeps being expensive though.

A better approach is using Red5 which is a Flash Media Server clone, with the difference this is open-source and free. The only problem is its lack of documentation and that its installation is not as straightforward as FMS. I’ll explain the installation process in Windows below.

Installing Red5

This process describes how to install Red5 version 0.9.1.

Download: Lets download the installer from http://code.google.com/p/red5/. Select the download depending on your operating system.

Install JDK: If you do not have Java installed, download the latest version from http://java.sun.com/javase/downloads/index.jsp. Download the right version for your 32 or 64 bits operating system.

Set the environment variables in Windows: You have to create a JAVA_HOME environment variable so that other applications and Red5 know where to find Java.

In Windows XP you have to right-click “My Computer” and select “Computer” properties, and then click the “Advanced” tab. In Windows Vista or 7 you have to right-click on “Computer” and select “Properties”, then click Advanced System Settings and the “Advanced” tab.

Click on Environment Variables. In “System Variables”, click the “New” button and type JAVA_HOME in the “Variable Name” box and the path were JDK installed in the “Variable Value” box. Let’s say you installed it in C:Program FilesJavajre1.6.0_23, it all depends on the version and settings you chose when installing.

There is an extra step for 64-bits versions of Windows. When you install Java, some files are copied to the C:WindowsSystem32 folder, but you also need to copy them in the C:WindowsSysWow64 folder. In this case you only need to copy the C:Program FilesJavajdk1.6.0_23binjava.exe file to C:WindowsSysWow64.

Installing RED5: Execute the Red5 installer (setup-Red5-0.9.1.exe). By default you install it in C:Program FilesRed5 or C:Program Files (x86)Red5 for 64 bits systems. When you are prompted for an IP address type 127.0.0.1. When prompted for a port type 5080.

Start the RED5 server: Open up the “Control Panel” and select Administrative Tools and then Services. In the list of services look for RED5. Select it and start the services by clicking the “Start service” link or by right clicking the service and selecting Start. If start is not enabled then the service is already running.

Testing RED5: To test RED5 open this URL in a browser http://localhost:5080/. The RED5 home page must open and if it does everything installed correctly. Before running the examples you must install them first. Open the following URL http://localhost:5080/installer/ select the example you want to install and press Install (install SOSample for example). Then from the Red5 home page (http://localhost:5080/) click “Launch a demo” to see the list of demos. We can now open the Shared Ball demo in many browser windows and click the connect icon on each of them to connect the samples to the server. Then if you drag the Red5 logo, you’ll see how it moves in the other browser windows as well.

And now what?

If you wish to see the source code, the server code is located inside the Red5 installation folder C:Program FilesRed5webapps or C:Program Files (x86)Red5webapps for 64 bits systems. To get the client Flash code you can use TortoiseSVN or any other subversion client to get them from http://red5.googlecode.com/svn/flash/trunk (Flash samples) or http://red5.googlecode.com/svn/flex/trunk (Flex samples). The Flash samples were written in ActionScript 2.0, so you’ll have to translate them to ActionScript 3.0 but this is not complicated.

If you don’t want to translate code you can write your own. To connect to Red5 you use the NetConnection class, to exchange data you use RSOs (Remote Shared Objects) and to send and receive audio/video use the NetStream class. To create en RSO just use the following line of code:

var rso:SharedObject = SharedObject.getRemote(
"NombreRSO", "rtmp://localhost/NombreApp");

You just have to play a little and see the samples to get the rest done.

How to create test suite using Junit and eclipse in selenium

How to create test suite using Junit and eclipse in selenium

There are some scenarios where we need to run multiple test cases. Either we can run those test cases independently or together. But there are some real time cases where we need to run our test cases in a particular order. In this case we would prefer Test Suite to combine the test cases together and decide their orders and run those.

Below are the steps

1. Create a Test Suite class where we create the Test Suites which will call all the test cases in a particular order.


import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;  
import junit.textui.TestRunner;

public class TestSuite1 extends TestCase {

public static Test suite()  
{  
TestSuite suite = new TestSuite();  

suite.addTestSuite( TestCase1.class);  
suite.addTestSuite( TestCase2.class);
suite.addTestSuite( TestCase3.class);  
return suite;  
}  

public static void main(String arg[])
{
TestRunner.run(suite());

}
}

Step 2. Create your first test case


import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase1 extends SeleneseTestCase{

Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;

public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();

}
public void testgoogling() {
selenium.open("/");
selenium.type("q", "Niraj");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("Niraj"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop();
}
}

Step 3. Create your second test case

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase2 extends SeleneseTestCase{
Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;
public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();
}

public void testgoogling() {
selenium.open("/");
selenium.type("q", "Niraj Kumar");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("Niraj Kumar"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop();
}
}

Step 4. Create your third test case

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase3 extends SeleneseTestCase{
Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;
public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();
}

public void testgoogling() {
selenium.open("/");
selenium.type("q", "http://www.automationtricks.blogspot.com");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("http://www.automationtricks.blogspot.com"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop(); 
}
}

Step 5. Run your Test Suite
Go to your Test Suite class and right click on that and run as Junit Test.

This will run the TestCase1 then TestCase2 then TestCase3

If you want to execute your test cases in some specific order then you call them in that order like.

suite.addTestSuite( TestCase3.class);  
suite.addTestSuite( TestCase2.class);
suite.addTestSuite( TestCase1.class);  

Above will run the TestCase3 first then TestCase2 then TestCase1.

Upgrading Selenium Standalone Server

Upgrading Selenium Standalone Server

I have started writing this blog from 3 months. When I have started writing the latest Selenium Standalone Server version available for download was 2.31.0.

Now I would like to check if there are any latest version available by following the below steps:

1. Open www.seleniumhq.org
2. Click on ‘Download’ tab to navigate to the downloads page as shown below:

3. In the Download page, view the latest version of the Selenium Standalone Server as shown below:

4. I’ve observed that there is a new version 2.32.0 for Selenium Server available for me to download  (currently I and using 2.31.0 version). So I would like to upgrade it to the latest version by following the below steps.

Upgrading to the Latest Selenium Server:

Pre-requisite: Ensure that Selenium Standalone Server is not running. If it is running, just restart the Eclipse IDE to stop it.

1. Download the Selenium Servers new version 2.32.0 and place the downloaded file in any folder as shown below:

2. In Eclipse IDE, Right click on the Project you are working with and select ‘Properties’ option as shown below:

3. Ensure that ‘Properties for Project’ dialog is displayed, select the older version of Selenium Server and click on ‘Remove’ button as shown below:

4. Ensure that the older version of Selenium Server is removed and click on ‘OK’ button as shown below:

5. Expand the libraries folder, right click on the older version of Selenium Server and click on ‘Delete’ option as shown below:

6. Click on ‘OK’ Button on the ‘Confirmation’ dialog as shown below:

7. Ensure that the older version got deleted from the libraries folder
8. Copy the latest version as shown below:

9. Paste the copied latest version into the libraries folder as shown below:

10. Ensure that the latest Standalone Server 2.32.0 got pasted into the libraries folder as shown below:

11. Right click on the Project and select Properties option as shown below:

12. Ensure that ‘Properties for Project’ dialog is displayed and click on ‘Add Jars’ button as shown below:

13. Ensure that ‘Jar Selection’ dialog is displayed, explain the Project -> libraries folder, select the latest selenium standalone version and click on ‘OK’ button as shown below:

14. Ensure that the latest Selenium Server version got added in the ‘Libraries’ tab and click on ‘OK’ button as shown below:

15. Select ‘External Tools Configuration’ option from the Run options as shown below:

16. Ensure that ‘External Tools Configuration’ dialog is displayed, change the version details in the ‘Argument’  text box and click on ‘Apply’ Button as shown below:

17. Click on ‘Run’ Button to start the ‘Selenium Server’ as shown below:

18. Ensure that the Selenium Server is running as shown below:

19. Run the ‘Class16.java’ file by selecting the ‘JUnit Test’ option as shown below:

20. Ensure that the Test got passed without any errors as shown below:

Watch the Below Video:

Click Here to watch the Video

Download this Project:

Click here to download this project and import into Eclipse IDE  on your machine.

Only one test should be written inside a test method

Only one test should be written inside a test method

1. Before going forward, lets once again view the code we have written in our previous post below: (i.e. The code with more than one tests inside a single test method)

2. As its not a good idea to write more than one tests inside a single test method, lets Refactor the Selenium Automation code by writing all the 3 tests into a separate test methods as shown below:

3. Start the Selenium Standalone Server
4. Save and Run the ‘Class16.java’ file by selecting the ‘JUnit Test’ option
5. In this case, Observe that the Firefox Browser has launched and closed for 3 times instead of once,  for performing the above three tests as shown in the below video.

Watch the Below Video:

Click Here to watch the video.

Download This Project:

Click here to download this project and import into Eclipse IDE  on your machine.

Why did the firefox launched and closed separately for each test method in the code ?

As we’ve three tests and we’ve written test method for each of our tests, hence we got 3 test methods in the Selenium Automation code. But in this case ‘chapter1’ page is common for 3 of the tests and hence its not required to close the application and launch it for performing the remaining tests. This has happened because of @Before and @After JUnit annotations.

The code inside the @Before and @After annotations will be executed once for each test method in our Selenium Automation code. Since we’ve three test methods in our code,  the methods under the @Before and @After got executed thrice (i.e. once for each test method).

How to resolve this problem ?

Suppose if we want to run the methods under the @Before and @After annotations only once, we’ve to replace these annotations with @BeforeClass and @AfterClass. (i.e. The method under @BeforeClass will be executed before executing all the test methods inside the class and The method under @AfterClass will be executed after executing all the test methods inside the class.

So to conclude the executing process will be as shown in the below screenshots:

@Before and @After:


@BeforeClass and @AfterClass:

You can research for implementation for the @BeforeClass and @AfterClass Annotations as well for confirmation.

%d bloggers like this: