The 15th Lanqiao Cup (Software Testing) Simulation Competition Issue 1 - Automation (50) & Unit (30) Test Questions (Java Language)

The 15th Lanqiao Cup (Software Testing) Simulation Competition Issue 1 - Automated Testing Questions (Java Language) (50 points) - Lanqiao Cloud Class

Automated test questions (Java language)

【Preliminary preparation】

Deploy the system under test according to the steps, and enter the access address of the system under test in the address bar of Firefox browser (v114 or above).

  • Access URL: Please view the URL of the successfully deployed system under test
  • Username: admin
  • Password: admin123

[Title description]

Please use the Java programming language, combined with the idea of ​​PO mode (abbreviation of Page Object Model), and use the Selenium automated testing tool to complete the missing code at //TODO in the following four Java class files (only fill in the missing code in the TODO part) , do not change other contents):

  • LoginPage.java: "User login" page.
  • AddUserPage.java: "Add User" page.
  • UserManagePage.java: "User Management" page.
  • WebCaseTest.java: test case.

Please follow the test case steps. In the test case WebCaseTest file, you need to complete the automated test code by calling three methods in the Page class.

[Use case steps]

The specific steps are as follows:

Step 1: Enter the URL of the system under test. Please check the URL of the system under test that has been deployed successfully.

Step 2: On the login page, ① enter [User Name] --> ② Enter [Password] --> ③ Click the [Login] button to log in, as shown in the figure below.

Step 3: Insert an assertion. After successful login, please assert whether the displayed user name is [Blue Bridge Super Management], as shown in the figure below.

Step 4: ①Click [System Management]-->②Click [User Management]-->③Click the [Add User] button, as shown in the figure below.

Tip: Pay attention to the switching of iframe here.

Step 5: On the new user page, ①Enter [User Name]-->②Enter [Login Account]-->③Enter [Login Password]-->④Check [Role] (ordinary role) -->⑤Click the [Save] button, as shown in the figure below.

Tip: Pay attention to the switching of iframe here.

Step 6: Insert the assertion and check whether the assertion is added successfully. The text content at ① in the figure below matches the expectation.

Step 7: As shown in the picture above, enter the newly added user ② [Login Name] in the search box, ③ click the [Search] button.

Step 8: Insert an assertion to determine whether the search results are correct. The text content at ① in the above figure matches the expectation.

Step 9: In the user list of the search results, delete the searched information and click the ④ [Delete] button behind the data, as shown in the figure above.

Step 10: Click ⑤ [Reset] to clear the search conditions, as shown in the picture above.

Step 11: Insert an assertion to assert that the text content at ① in the search results matches what is expected.

Step 12: Click on the [Blue Bridge Super Management] avatar and click [Log out], as shown in the figure below.

Tip: Pay attention to the switching of iframe here.

【Tool operation】

Step 1: Please click to downloadAutomated test Java source code package to your local computer. The source code package includes the following 4 files:

  • Login page class LoginPage.java
  • Add user class AddUserPage.java
  • Search User Class SearchUserPage.java
  • Test case class WebCaseTest.java

Step 2: Please copy the above 4 files to the corresponding locations in the Eclipse tool,JavaLanqiaoTest/test/cn.lanqiao.web, as shown in the figure below. Then fill in the missing test code at //TODO.

Note: This position cannot be changed at will, otherwise the wrong package name will cause a compilation error and 0 points will be awarded.

[Topic requirements]

  1. Candidates can choose the element positioning method they are good at. It is recommended to use xpath or css positioning method.
  2. Please use appropriate waiting methods during operation to avoid script failure.
  3. Please use // for code comments.
  4. In the test case's class file, call the methods in the Page class file to complete the test case.
  5. Do not fill in the iframe switching code in the Page class, write it in the WebCaseTest class file.
  6. The assertion Assert class used in testing must use Assert in the org.junit package.
  7. Do not modify the file name and original code.

[Scoring criteria]

  1. The implementation of 3 methods in the Page class is worth 1 point each, for a total of 18 points.
  2. The WebCaseTest.java test case is scored from two aspects: specification and test case coverage, with a total of 32 points.
    • Specifications (4 points in total): 1) Failure to use the waiting method reasonably, 4 points will be deducted.
    • Test Case (Total 28 points) 1) A total of 16 key test case steps, each step is worth 1 point, a total of 16 points. (If the use case step fails, the remaining use cases will not be scored.) 2) There are 4 assertions in total, each assertion is worth 3 points, for a total of 12 points. If the assertion fails to run, no points will be given; if the assertion runs successfully, points will be given based on the number of passes.
  3. If the entire project code fails to compile, the method score and test case score in the Page will be deducted, but the specification score will not be affected.

【Answer submission】

After completing all the answers, the following 4 files in this question are the answer files we need, as follows:

  • LoginPage.java
  • AddUserPage.java
  • SearchUserPage.java
  • WebCaseTest.java

The file location is:C:\LanQiaoTest\project\JavaLanqiaoTest\test\cn\lanqiao\web. Please copy these 4 files to the local [Answer Submission] folder and wait for final submission together with the functional test answers and unit test answers.


Unit test questions (Java)

[Title description]

Please usebasic path method to design unit test cases for the grouping method in the GroupCompetition class of the source code under test. And complete the unit test code in the GroupCompetitionTest class.

[Source code function]

The function implemented by the source code is: grouping the semi-finals according to age and preliminary results. The specific grouping rules are as follows:

  • Those who are older than 18 years old or whose score in the preliminary round is less than 60 points will not be eligible for the rematch;
  • If the age is less than or equal to 12 years old, and the score in the preliminary round is greater than or equal to 80 points, the semi-final group will be "Children's Group A"; if the preliminary round score is less than 80 points, the semi-final group will be "Children's Group B";
  • If you are older than 12 years old and have a score of 80 points or more in the preliminary round, you will be divided into the "Youth Group A" in the semi-finals; if you are less than 80 points in the preliminary round, you will be grouped in the "Youth Group B" in the semi-finals.

【Tool operation】

  1. Please click to download Unit test Java source code package to your local computer, including the following 2 files:
  • Tested source code file GroupCompetition.java
  • Test code file GroupCompetitionTest.java
  1. Please copy the above 2 files to the corresponding locations in the Eclipse tool, and then start filling in the unit test code. The file location is shown below.

Note: This position cannot be changed at will, otherwise the wrong package name will cause a compilation error and 0 points will be awarded.

[Topic requirements]

  1. Please use basic path coverage method to design 6 test cases so that the basic path coverage of the code under test reaches 100%.
  2. Please use the Java language unit testing framework Junit to write test code.
  3. Please write the test code directly in the provided class file GroupCompetitionTest.java.
  4. The assertion Assert class used in testing must use Assert in the org.junit package.
  5. Please do not modify the file name provided, otherwise 0 points will be assessed at your discretion.
  6. When submitting your answer, please do not modify the encoding of the file.

[Scoring criteria]

The full score is 30 points, and the specific scoring details are as follows:

  • Code specifications: 5 points
  • Test case coverage: 25 points
  • Running results: If the run is unsuccessful, all test case coverage scores will be deducted, but the code specification score will not be affected.

【Answer submission】

The unit test code file GroupCompetitionTest.java is the answer we need. The file location is:C:\LanQiaoTest\project\JavaLanqiaoTest\test\cn\lanqiao\unit, as shown in the following figure:

Please copy this file to the local [Answer Submission] folder and wait until it is finally submitted together with the functional test answers and automated test answers.

Guess you like

Origin blog.csdn.net/m0_67184231/article/details/134794018