Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve acceptance tests #100

Merged
merged 8 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ atest/report.html
atest/screenshot/
atest/logs/
atest/screenshots/
/Work

# Python virtual environment
.venv
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Here are some guidelines to help you get started:
- When creating new user keywords, please provide documentation.
- Write tests for your changes. You may need to include unit tests, acceptance tests, or both, depending on the change you made.
- Format your code by running `inv lint` from the cloned folder.
- Ensure all tests pass by running `inv utest` for unit tests and `inv atest` for acceptance tests.
- Ensure all tests pass by running `inv utest` for unit tests and `inv atest` for acceptance tests again from the cloned folder.
- Push your changes to your fork on GitHub.
- Create a pull request.

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ docker run --user mfuser -v /path/to/your/tests:/home/mfuser/tests mainframe3270

Interested in contributing to the project? Great to hear! Whether you found a bug, or want to develop a new feature, please refer to our [Contributing Guidelines](CONTRIBUTING.md) to help you get started.

## Keyword Tests

To run all the library tests, you will need to create a user on the [pub400](https://www.pub400.com/) website.

## WIKI
## Wiki
For more information visit the repository [Wiki](https://github.com/Altran-PT-GDC/Robot-Framework-Mainframe-3270-Library/wiki).

## Changelog
For an overview of the (latest) changes see [CHANGELOG](CHANGELOG.md).

## Authors
- **Altran -** [Altran Web Site](https://www.altran.com/us/en/)
- **Samuel Cabral**
Expand Down
5 changes: 3 additions & 2 deletions atest/connection.robot
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ Create Session File
${session_file}= Set Variable ${CURDIR}/resources/session.s3270
END
Copy File ${SESSION_TEMPLATE} ${session_file}
RETURN ${session_file}
# Using legacy [Return] for older RF versions
[Return] ${session_file}

Test Teardown
Close Connection
Run Keyword And Ignore Error Close Connection
Sleep 1 second
Remove File ${TRACE_FILE}
91 changes: 46 additions & 45 deletions atest/mainframe.robot
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
*** Settings ***
Documentation These tests verify that all keywords are working correctly and displaying the expected exception message.
... To run all the tests, you will need to create a user in the https://www.pub400.com/ website,
... this will affect the last test "Test With Login"
Documentation These tests verify that all keywords are working correctly and displaying the expected exception messages.

Library ../Mainframe3270/ run_on_failure_keyword=None
Library Dialogs
Library OperatingSystem
Library String
Resource pub400_variables.robot
Expand All @@ -17,32 +14,33 @@ Suite Teardown Suite Teardown
Exception Test Read
Wait Field Detected
${read_text} Read 1 10 21
Run Keyword And Expect Error ${WELCOME_TEXT_EXPECTED_ERROR} Should Be Equal As Strings ${WELCOME_TITLE}
Run Keyword And Expect Error
... ${WELCOME_TEXT_EXPECTED_ERROR}
... Should Be Equal As Strings
... ${WELCOME_TITLE}
... ${read_text}
Run Keyword And Expect Error ${X_AXIS_EXCEEDED_EXPECTED_ERROR} Read 4 48 34
Run Keyword And Expect Error ${X_AXIS_EXCEEDED_EXPECTED_ERROR} Read 4 81 1
Run Keyword And Expect Error ${Y_AXIS_EXCEEDED_EXPECTED_ERROR} Read 25 48 34

Exception Test Write In Position
Run Keyword And Expect Error ${X_AXIS_EXCEEDED_EXPECTED_ERROR} Write In Position ${WRITE_TEXT} 10 81
Run Keyword And Expect Error ${Y_AXIS_EXCEEDED_EXPECTED_ERROR} Write In Position ${WRITE_TEXT} 25 10

Exception Test Write Bare In Position
Run Keyword And Expect Error
... ${X_AXIS_EXCEEDED_EXPECTED_ERROR}
... Write In Position
... Write Bare In Position
... ${WRITE_TEXT}
... 10
... 81
Run Keyword And Expect Error
... ${Y_AXIS_EXCEEDED_EXPECTED_ERROR}
... Write In Position
... Write Bare In Position
... ${WRITE_TEXT}
... 25
... 10

Exception Test Write Bare In Position
Run Keyword And Expect Error ${X_AXIS_EXCEEDED_EXPECTED_ERROR} Write Bare In Position ${WRITE_TEXT} 10
... 81
Run Keyword And Expect Error ${Y_AXIS_EXCEEDED_EXPECTED_ERROR} Write Bare In Position ${WRITE_TEXT} 25
... 10

Exception Test Page Should Contain String
Verify String Not Found Page Should Contain String ${WELCOME_WRONG_CASE}
Verify String Not Found Page Should Contain String ${STRING_NON_EXISTENT} ignore_case=${True}
Expand All @@ -54,16 +52,27 @@ Exception Test Page Should Contain All Strings
... ${LIST_STRINGS_WRONG_CASE_IN_THE_SECONDS}
... 2
Verify String Not Found In List Page Should Contain All Strings ${LIST_STRINGS_WRONG_CASE_IN_THE_THIRD} 3
Verify String Not Found In List Page Should Contain All Strings ${LIST_STRINGS_WRONG_IN_THE_FIRST} 1
Verify String Not Found In List
... Page Should Contain All Strings
... ${LIST_STRINGS_WRONG_IN_THE_FIRST}
... 1
... ignore_case=${True}
Verify String Not Found In List Page Should Contain All Strings ${LIST_STRINGS_WRONG_IN_THE_SECOND} 2
Verify String Not Found In List
... Page Should Contain All Strings
... ${LIST_STRINGS_WRONG_IN_THE_SECOND}
... 2
... ignore_case=${True}
Verify String Not Found In List Page Should Contain All Strings ${LIST_STRINGS_WRONG_IN_THE_THIRD} 3
Verify String Not Found In List
... Page Should Contain All Strings
... ${LIST_STRINGS_WRONG_IN_THE_THIRD}
... 3
... ignore_case=${True}

Exception Test Page Should Contain Any String
Verify List Not Found Page Should Contain Any String ${LIST_STRINGS_ALL_WRONG_CASE}
Verify List Not Found Page Should Contain Any String ${LIST_STRINGS_NON_EXITENT_IGNORE_CASE}
Verify List Not Found
... Page Should Contain Any String
... ${LIST_STRINGS_NON_EXITENT_IGNORE_CASE}
... ignore_case=${True}

Exception Test Page Should Contain Match
Expand All @@ -72,8 +81,12 @@ Exception Test Page Should Contain Match

Exception Test Page Should Contain String X Times
Verify String Does Not Appear X Times Page Should Contain String X Times ${TEXT_TO_COUNT} 1 3
Verify String Does Not Appear X Times Page Should Contain String X Times ${TEXT_TO_COUNT_WRONG_CASE} 1
... 5 ignore_case=${True}
Verify String Does Not Appear X Times
... Page Should Contain String X Times
... ${TEXT_TO_COUNT_WRONG_CASE}
... 1
... 5
... ignore_case=${True}

Exception Test Page Should Match Regex
Verify Pattern Not Found Page Should Match Regex ${INVALID_REGEX}
Expand Down Expand Up @@ -191,7 +204,7 @@ Test Move Next Field
Sleep 1s

Test Move Previous Field
# Send two Move Previous Field because the first only put the cursor int he beginning of the password field
# Send two Move Previous Field because the first only puts the cursor at the beginning of the password field
Move Previous Field
Move Previous Field
Write Bare ${WRITE_TEXT}
Expand All @@ -200,34 +213,16 @@ Test Move Previous Field
Sleep 1s

Test Send Enter
[Tags] no-ci
Wait Field Detected
Page Should Contain String ${WELCOME}
Page Should Contain String ${WELCOME_WRONG_CASE} ignore_case=${TRUE}
Delete Field
${user} Get Value From User Write user
${password} Get Value From User Write user password
Write Bare In Position ${user} 5 25
Move Next Field
Write Bare ${password}
Delete Field
Send Enter
${value} Read 1 33 15
Should Be Equal As Strings ${MAIN_MENU} ${value}
Take Screenshot
Page Should Contain String Sign-on information required.

Test Send PF
[Tags] no-ci
Write 1
Wait Field Detected
Take Screenshot
Page Should Contain String ${USER_TASK}
Send PF 12
Wait Field Detected
Take Screenshot
Page Should Contain String ${MAIN_MENU}
Write 90
Wait Field Detected
Take Screenshot
Send PF 1
Page Should Contain String Function key not allowed.


*** Keywords ***
Expand All @@ -241,7 +236,7 @@ Suite Setup
Sleep 3s

Suite Teardown
Close Connection
Run Keyword And Ignore Error Close Connection
Sleep 1s

Verify String Not Found
Expand All @@ -251,7 +246,9 @@ Verify String Not Found

Verify String Not Found In List
[Arguments] ${keyword} ${string_list} ${string_position} ${ignore_case}=${False}
${not_found_string} Set Variable If ${ignore_case}==${False} ${string_list[${${string_position}-1}]}
${not_found_string} Set Variable If
... ${ignore_case}==${False}
... ${string_list[${${string_position}-1}]}
... ${string_list[${${string_position}-1}].lower()}
${expected_error} Set Variable The string "${not_found_string}" was not found
Run Keyword And Expect Error ${expected_error} ${keyword} ${string_list} ignore_case=${ignore_case}
Expand Down Expand Up @@ -280,7 +277,11 @@ Verify String Does Not Appear X Times
... ${ignore_case}=${False}
${expected_error} Set Variable
... The string "${string}" was not found "${wrong_number_of_times}" times, it appears "${right_number_of_times}" times
Run Keyword And Expect Error ${expected_error} ${keyword} ${TEXT_TO_COUNT} 1
Run Keyword And Expect Error
... ${expected_error}
... ${keyword}
... ${TEXT_TO_COUNT}
... 1
... ignore_case=${ignore_case}

Verify String Found
Expand Down
2 changes: 1 addition & 1 deletion atest/run_on_failure/custom_keyword_on_import.robot
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Custom Run On Failure Keyword
Create File ${CUSTOM_FILE} An error ocurred

Close Mainframe
Close Connection
Run Keyword And Ignore Error Close Connection
Sleep 1 second
2 changes: 1 addition & 1 deletion atest/run_on_failure/none_on_import.robot
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Cause Error
... Page Should Contain String ${STRING_NON_EXISTENT}

Close Mainframe
Close Connection
Run Keyword And Ignore Error Close Connection
Sleep 1 second
2 changes: 1 addition & 1 deletion atest/run_on_failure/run_on_failure.robot
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Custom Run On Failure Keyword
Create File ${CUSTOM_FILE} An error ocurred

Close Mainframe
Close Connection
Run Keyword And Ignore Error Close Connection
Sleep 1 second
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def lint_python(c):
@task
def lint_robot(c):
"""Perform robot code formatting with robotidy."""
c.run("robotidy atest/")
c.run("robotidy --configure ReplaceReturns:enabled=False atest/")


@task(lint_python, lint_robot)
Expand Down