Reference no: EM133673729
Task: Integrate web frontend with Java API back end as part of integration testing
Overview
Web applications are often developed as separate frontend and backend modules where HTML based front ends (or web pages or client interface) interact with the back end (or cloud) through welldefined APIs to receive services including authentication and access cloud resources. Development of front and back ends may progress separately until they are merged to test their integration. In this task you will need to develop HTML pages which will then communicate to the HTTP endpoints (such as Java Servlets). These backend HTTP request handlers invoke business logic to provide services such as a login service that can access user directory or database to authenticate a login request. You will need to create business logic functions as needed and unit test them as you develop - wearing a developer hat to test all your function features. Next you will need to use login HTML pages and use selenium to do functional testing of this page - wearing a software quality assurance team member's hat. The main goal wearing both hats would be to test the software to break it from dev team and testing team's point of view. This also facilitates to experience an integration testing - connecting frontend to back end. In addition, you would need to justify if the tests generated in this task covered aspects of integration testing and at what level and recommend, if any.
Submission details
Use the instructions on the following page to carry out this task's steps. Submit the following files to OnTrack.
A PDF file listing unit test cases from developer pointofview and functional test cases from testteam pointofview. You can use a table to describe each test case name, description, intended result and test results.
A selfreflection on the difference between writing test cases for developers themselves (unit tests) and testing teammembers (functional tests). Justify your findings w.r.t. a Venn diagram specially, any untested regions of functional requirements.
Your justification regarding aspects of integration testing this project covers.
Your program's source code.
A screenshot of your GitHub page where your latest project folder is pushed.
You want to focus on the following key ideas, and make sure you can explain them in relation to your program.
Unit testing and functional testing.
Satisfy functional specifications.
Integration tests in terms of functional testing (integrating frontend with the back end).
Instructions
For this task you will need to
Download task8_1P.zip Java project and unzip it in a common folder (say, java_projects) which you will be using to store all the weekly projects.
Import the project (as a maven project) in Eclipse IDE.
Observe the project folder structure as below
Directory structure MyServer.java
File name Description
MyServer.java
Package: web HTTP server module, you need to run this file to start web server. It listens to port 8082. Open URL https://127.0.0.1:8082 in a browser and you should see a greeting message from the running
server.
WelcomeServlet.java
package: web.handler Handles URL / and displays a greeting
message.
LoginServlet.java
Package: web.handler Handles URL /login and calls
LoginService.login() function to authenticate user.
RegistrationServlet.java
Package: web.handler Handles URL /reg and calls RegistrationService.register() function.
PASS tasks can leave this function as it is.
The /login URL is routed to LoginServlet which extracts HTML form parameters such as username, password and DoB and calls LoginService.login() to authenticate user. The login function does not make use of DoB field in the example which you need to use for authentication. Finally, renders a HTML string to display on browser as a response. Note that the generated HTML string creates page title to reflect the login status, this is to help to test the response by checking the page title from Selenium. You can come up with your own response mechanism so that a form submission response can be validated from Selenium side.
LoginServlet.java
LoginService.java
As a developer, you must update the login function to make use of all 3 parameters such as username, password and dob (date string format yyyymmdd) and generate
unit test cases to test to cover any anomaly using one or more of boundary value, equivalence class or decisiontable based tests as appropriate.
As a testteam member, you must use Selenium to write functional test cases by loading login.html and testing the login function and aim to find function flaws by using all ranges of values including valid and invalid values. You may need to update Java files in web.service package (LoginService.java) to enhance the authentication logic and unit test them and update Java files in web.handler package (LoginServlet.java) to generate authentication response which can be easily tested in Selenium. Currently response HTML page's title is set to string ‘success' or 'fail' based on authentication logic. You may not require updating login.html file, but you should keep the fields same (username, password, and dob).
Login.html
Web view
Selenium test example is shown in below figure and described in a table.
Line 4048 Locates fields including username and passwd and fills in new values.
Line 5253 Locates submit button and clicks on it to submit the form.
Line 64 Verifies authentication response if it equals to a page title "success".
LoginServiceTest.java
You will need to update the LoginServiceTest.java file to add additional functional test cases using Selenium.
You will need to create a new test file to include your unit test cases.
Upload your project folder to your GitHub account and take a screenshot.
Your Task
For this task, you will need to
Study login.html page and webserivce1 Eclipse Java project's source and test files to understand how the HTML form in login.html is submitted to interact with Java web handler function located in LoginServlet.java. For this, you will need to run the MyServer.java file to start HTTP web server.
Improve authentication logic in LoginService.java and write unit test cases (create a new test file) to cover above 90% code coverage.
Update LoginServlet.java to generate HTTP response suitable for Selenium to receive it so functional tests can be done easily. Currently, the response web page's title reflects the authentication response.
Update LoginServiceTest.java to include more functional test cases based on Selenium.
Your goal should be to critically write test cases from both developer and testteam member's point of view to find flaws in the system.
Follow submission instructions on the first page and submit your work.