Category Archives: JavaCode

Automation Testing with Selenium IDE

Test automation means using a software tool to run repeatable tests against the application to be tested.

Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. Selenium is not just a single tool but a suite of softwares, each catering to different testing needs of an organization. It has four components.

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • WebDriver
  • Selenium Grid

Many people get started with Selenium IDE. Using the IDE you can create simple tests quickly, sometimes within seconds.
Selenium IDE
– The tool you use to develop your test cases.
– Firefox plug-in

Download the tutorial document here:

[Java] Compare two list


I have two classes are Employee and Department

class Department{
private Long deptId;
private String deptName;

public Long getDeptId() {
return deptId;
public void setDeptId(Long deptId) {
this.deptId = deptId;
public String getDeptName() {
return deptName;
public void setDeptName(String deptName) {
this.deptName = deptName;

class Employee{
private Long empId;
private String empName;
private Department dept;

public Employee() {

public Employee(Long empId, String empName, Department dept) {
this.empId = empId;
this.empName = empName;
this.dept = dept;
public Long getEmpId() {
return empId;
public void setEmpId(Long empId) {
this.empId = empId;
public String getEmpName() {
return empName;
public void setEmpName(String empName) {
this.empName = empName;
public Department getDept() {
return dept;
public void setDept(Department dept) {
this.dept = dept;


And, I write  a class for compare two list with data from Employee class: ListComparisonTest

package tdd.sprint10;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.*;

public class ListComparisonTest {

private Department dept;

public ListComparisonTest() {

public void setUp() throws Exception {
dept=new Department();

public void tearDown() throws Exception {

public void testCompareList() {
Employee emp1 = new Employee();
emp1.setEmpName("Van Huong");

Employee emp2 = new Employee();
emp2.setEmpName("Xuan Vinh");

List<Employee> firstList = new ArrayList<Employee>();

List<Employee> secondList = new ArrayList<Employee>();
secondList.add(new Employee(1L,"Van Huong",dept));
secondList.add(new Employee(2L,"Xuan Vinh",dept));

assertEquals(firstList.size(), secondList.size());


It’s fail when I  run the test class with JUnit Test!

The solution: create hashCode() and equals() functions on Employee class

On Eclipse IDE, press Alt + Shift + S, chose  generate and hashCode() and equals() functions.

public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dept == null) ? 0 : dept.hashCode());
result = prime * result + ((empId == null) ? 0 : empId.hashCode());
result = prime * result + ((empName == null) ? 0 : empName.hashCode());
return result;

public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (dept == null) {
if (other.dept != null)
return false;
} else if (!dept.equals(other.dept))
return false;
if (empId == null) {
if (other.empId != null)
return false;
} else if (!empId.equals(other.empId))
return false;
if (empName == null) {
if (other.empName != null)
return false;
} else if (!empName.equals(other.empName))
return false;
return true;

Advanced programming

Tự học lập trình Android, android wear - lập trình smartwatch, Windows phone, Web service, C++, C#, java, Swift, Python, kotlin...

Tôi IT - Change the world

Research + Technical -> Programming,

Building A Business While Having A Life


No Pain No Gain

Study and Share's Blog

Việt Nam tươi đẹp...


One of the best way to learn is by writing to the paper.