In many cases with unit tests there are cases where you want to test how your application interacts with a database without actually connecting to and obtaining database records from the RDBMS. In my case, I am working with a large industrial application that connects with a database, but it is not a common database like Oracle or SQL Server.
Presently, the tests run for about 24 hours to complete the execution of all of the tests, where we are trying to make the test as much like the “real world” as possible, but we also have another mode that runs through all of the tests but ideally, it would be finished all of the tests in about 1 hour.
In my experience with C#/.NET, I have used tools to a create “fake” in-memory databases for testing using E.F.F.O.R.T. (see https://entityframework-effort.net/) or Moq (see https://learn.microsoft.com/en-us/shows/visual-studio-toolbox/unit-testing-moq-framework) before but I am not sure off the top of my head how to do that with Python Robot so I was wondering if anyone here has any suggestions.
Is it possible to perform tests without actually “hitting the database” with the robot framework? In my case the tests framework is python which is actually calling and exercising a C#/.NET application.
Here is what the source code looks like:
*** Settings ***
Resource ../../../Resources.robot
Library Process
Suite Setup Do Suite Setup
Suite Teardown Do Suite Teardown
Test Setup Do Test Setup
Test Teardown Do Test Teardown
Test Template Test Results of A ${pressure_type} Pressure Exceeding HighLimit Using Config ${config_file}
Default Tags RobotFrameworkCompatible
*** Keywords ***
Do Suite Setup
Set Default Protection Type HighPressure
Set Suite Variable ${bypass.status} d459ba36-221b
Do Suite Teardown
Set current_status Attribute For Status Point ${bypass.status} To 0
Do Test Teardown
Stop PressureProtection
Do Test Setup
Set current_status Attribute For Status Point ${bypass.status} To 0
*** Keywords ***
Initialize Test for HPP Pressure Type ${pressure_type} using config ${config_file}
${PressureProtection_config} = Join Path ${CURDIR} ${config_file}
Start PressureProtection with config ${PressureProtection_config}
Wait for 2s
Set Default HPP Pressure Type ${pressure_type}
Disable all stations
Set Safe Pressure at location OS0
Set Safe Pressure at location OS1
Set Safe Pressure at location OS2
Set Safe Pressure at location OS3
Set Safe Pressure at location OS4
Set Safe Pressure at location OS5
Disable all stations
At Location OS0 set opMode to disabled
At Location OS1 set opMode to disabled
At Location OS2 set opMode to disabled
At Location OS3 set opMode to disabled
At Location OS4 set opMode to disabled
At Location OS5 set opMode to disabled
Set Safe Pressure at location ${station}
At Location ${station} set pressure to 1
At Location ${station} set highLimit to 1000
Enable all stations
At Location OS0 set opMode to enabled
At Location OS1 set opMode to enabled
At Location OS2 set opMode to enabled
At Location OS3 set opMode to enabled
At Location OS4 set opMode to enabled
At Location OS5 set opMode to enabled
At Location OS5 Set Pressure Over Limit and expect commout and stop line immediately to impact upstream stations
At Location OS5 set pressure to 1001
Wait for ${SECONDS_TO_RAISE_ALARM}s
At Location OS5 expect Commout and Stop Line Immediately to impact ${UPSTREAM_OF_STATION5} in the last ${SECONDS_TO_CHECK_FOR_RAISED_ALARM}s
# sanity checks; of course none of this stuff should trigger
At Locations ${ALL_STATIONS} expect no Cascade Shutdown Command in the last ${SECONDS_TO_CHECK_FOR_RAISED_ALARM}s
At Locations ${ALL_STATIONS} expect no Cascade Reset Command in the last ${SECONDS_TO_CHECK_FOR_RAISED_ALARM}s
Expect NO Stop Stations Alarm at locations ${UPSTREAM_OF_STATION5} in the last ${SECONDS_TO_CHECK_FOR_RAISED_ALARM}s
Test Results of A ${pressure_type} Pressure Exceeding HighLimit Using Config ${config_file}
[Documentation] Assumption is OS5 is configured as "DriveUpstreamToCommoutAndShutdownImmediately"
Initialize Test for HPP Pressure Type ${pressure_type} using config ${config_file}
At Location OS5 set pressure to 600
Wait for ${SECONDS_TO_RAISE_ALARM}s
Enable all stations
Wait for ${SECONDS_TO_RAISE_ALARM}s
At Location OS5 Set Pressure Over Limit and expect commout and stop line immediately to impact upstream stations
At Location OS5 set pressure to 1000
Wait for ${SECONDS_TO_RAISE_ALARM}s
At Location OS5 expect an alarm 'Pressure returned to normal' in the last ${SECONDS_TO_CHECK_FOR_RAISED_ALARM}s
Set current_status Attribute For Status Point ${bypass.status} To 1
Wait for ${SECONDS_TO_RAISE_ALARM}s
At Location OS5 Set Pressure Over Limit and expect commout and stop line immediately to impact upstream stations
*** Test Cases ***
Suction Test Suction suction_config.yaml
Discharge Test Discharge discharge_config.yaml
Case Test Case case_config.yaml
Does anyone have any suggestions? TIA.