Monday, March 30, 2015

How to perform Negative Testing?

How to perform Negative Testing?
Ans:
                Objectives: Failure Message will be shown.
                Problems/ Issues:
·         Implementation is not done properly.
·         Success message is shown on that specific case.
Solution/ Checking procedure:
·         On that case, first check the success message has shown or not. If success message is shown, then the failure message is not exists.
Code:
                        Part1:
public boolean checkFileBigSizeAlertExists() throws NumberFormatException, IOException {
                         try { 
                                  waitForElement(successMsgOfEmpUpdate, Integer.valueOf(PropertyLoader.loadProperty("implicit_timeout_sec_120")));
if (driverW.findElement(By.cssSelector(".page-con.page-con-ajax .alert.alert-success")) != null) {
                                                  return false;
                                    } else {
                                                 return true;
                                    }
                          } catch (NoSuchElementException e) {
                                    return true;
                          }
                  }
                        Part2:
                        boolean bigSizeAlertExists = employeesPage.checkFileBigSizeAlertExists();
                        Assert.assertEquals(bigSizeAlertExists, true, "Profile picture with extra size succuessfully uploaded");

Monday, March 23, 2015

Make a Maven Project



Make a Maven Project:
Step - 1:
Java path set as
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_51
PATH = ;%JAVA_HOME%\bin;

Step - 2:
First extract the apache-maven-3.2.5-bin.tar.gz file. Then go to "Environment Setting". Make a path to bin folder of maven.
PATH = ;C:\apache-maven\bin;

Step - 3:
Then restart the PC and check in command prompt as
mvn -v

It will give as below:
C:\Users\USER>mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T02:29:23+09:00)
Maven home: C:\apache-maven\bin\..
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_51\jre
Default locale: en_US, platform encoding: MS932
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\Users\USER>

Step - 4:
Next open the command prompt. Then go to project folder.
My folder is
E:\workspace\test
Then run the command.
mvn eclipse:eclipse

Map: Map inside Map



Map inside Map:
Base.java:

Initialization:
public static Map<String, Map<String, String>> roles = new HashMap<>();
public static String SCHOOL = "school";
public static String HOSPITAL = "hospital";

Call from method:
this.createRoleMap();

Implementation:
                private void createRoleMap() {
                                Map<String, String> hospital = new HashMap<>();
                                hospital.put("admin", "Admin");
                                hospital.put("physician", "Physician");
                                hospital.put("nurse", "Nurse");
                                hospital.put("fieldtechnician", "Field Technician");
                                hospital.put("staff", "Nurse");
                                roles.put(HOSPITAL, hospital);

                                Map<String, String> school = new HashMap<>();
                                school.put("admin", "Admin");
                                school.put("physician", "Staff Member");
                                school.put("nurse", "Staff Member");
                                school.put("fieldtechnician", "Staff Member");
                                school.put("staff", "Staff Member");
                                roles.put(SCHOOL, school);
                }