One Page Acceptance testing.
This class will help you write acceptance tests in one page or single page applications. You can wait for certain conditions to be met.
new sap.ui.test.Opa(extensionObject?)
Param | Type | Default Value | Description |
---|---|---|---|
extensionObject? | object | An object containing properties and functions. The newly created Opa will be extended by these properties and functions using jQuery.extend. |
Method | Description |
---|---|
emptyQueue |
Calls the static emptyQueue function in the Opa namespace sap.ui.test.Opa.emptyQueue |
sap.ui.test.Opa.emptyQueue |
Waits until all waitFor calls are done. |
extendConfig |
Calls the static extendConfig function in the Opa namespace sap.ui.test.Opa.extendConfig |
sap.ui.test.Opa.extendConfig |
Extends and overwrites default values of the sap.ui.test.Opa.config field. Sample usage:
|
getContext |
Gives access to a singleton object you can save values in. This object will only be created once and it will never be destroyed. That means you can use it to save values you need in multiple separated tests. |
sap.ui.test.Opa.getContext |
Gives access to a singleton object you can save values in. Same as sap.ui.test.Opa#getContext |
iWaitForPromise |
Schedule a promise on the OPA queue.The promise will be executed in order with all waitFors - any subsequent waitFor will be executed after the promise is done. The promise is not directly chained, but instead its result is awaited in a new waitFor statement. This means that any "thenable" should be acceptable. |
sap.ui.test.Opa.resetConfig |
Reset Opa.config to its default values. All of the global values can be overwritten in an individual waitFor call. The default values are:
|
sap.ui.test.Opa.stopQueue |
Clears the queue and stops running tests so that new tests can be run. This means all waitFor statements registered by sap.ui.test.Opa#waitFor will not be invoked anymore and the promise returned by sap.ui.test.Opa.emptyQueue will be rejected When it is called inside of a check in sap.ui.test.Opa#waitFor the success function of this waitFor will not be called. |
waitFor |
Queues up a waitFor command for Opa. The Queue will not be emptied until sap.ui.test.Opa.emptyQueue is called. If you are using module:sap/ui/test/opaQunit, emptyQueue will be called by the wrapped tests. If you are using Opa5, waitFor takes additional parameters. They can be found here: sap.ui.test.Opa5#waitFor. Waits for a check condition to return true, in which case a success function will be called. If the timeout is reached before the check returns true, an error function will be called. |
Calls the static extendConfig function in the Opa namespace sap.ui.test.Opa.extendConfig
Extends and overwrites default values of the sap.ui.test.Opa.config field. Sample usage:
var oOpa = new Opa();
// this statement will time out after 15 seconds and poll every 400ms
// those two values come from the defaults of sap.ui.test.Opa.config
oOpa.waitFor({
});
// All wait for statements added after this will take other defaults
Opa.extendConfig({
timeout: 10,
pollingInterval: 100
});
// this statement will time out after 10 seconds and poll every 100 ms
oOpa.waitFor({
});
// this statement will time out after 20 seconds and poll every 100 ms
oOpa.waitFor({
timeout: 20;
});
Param | Type | DefaultValue | Description |
---|---|---|---|
options | object |
The values to be added to the existing config |
Gives access to a singleton object you can save values in. This object will only be created once and it will never be destroyed. That means you can use it to save values you need in multiple separated tests.
Gives access to a singleton object you can save values in. Same as sap.ui.test.Opa#getContext
Schedule a promise on the OPA queue.The promise will be executed in order with all waitFors - any subsequent waitFor will be executed after the promise is done. The promise is not directly chained, but instead its result is awaited in a new waitFor statement. This means that any "thenable" should be acceptable.
Param | Type | DefaultValue | Description |
---|---|---|---|
oPromise | jQuery.promise Promise |
promise to schedule on the OPA queue |
Reset Opa.config to its default values. All of the global values can be overwritten in an individual waitFor call.
The default values are:
Clears the queue and stops running tests so that new tests can be run. This means all waitFor statements registered by sap.ui.test.Opa#waitFor will not be invoked anymore and the promise returned by sap.ui.test.Opa.emptyQueue will be rejected When it is called inside of a check in sap.ui.test.Opa#waitFor the success function of this waitFor will not be called.
Queues up a waitFor command for Opa. The Queue will not be emptied until sap.ui.test.Opa.emptyQueue is called. If you are using module:sap/ui/test/opaQunit, emptyQueue will be called by the wrapped tests.
If you are using Opa5, waitFor takes additional parameters. They can be found here: sap.ui.test.Opa5#waitFor. Waits for a check condition to return true, in which case a success function will be called. If the timeout is reached before the check returns true, an error function will be called.
Param | Type | DefaultValue | Description |
---|---|---|---|
options | object |
These contain check, success and error functions |
|
timeout | int |
default: 15 - (seconds) Specifies how long the waitFor function polls before it fails.O means it will wait forever. |
|
debugTimeout | int |
@since 1.47 default: 0 - (seconds) Specifies how long the waitFor function polls before it fails in debug mode.O means it will wait forever. |
|
pollingInterval | int |
default: 400 - (milliseconds) Specifies how often the waitFor function polls. |
|
asyncPolling | boolean |
@since 1.55 default: false Enable asynchronous polling after success() call. This allows more stable autoWaiter synchronization with event flows originating from within success(). Especially usefull to stabilize synchronization with overflow toolbars. |
|
check | function |
Will get invoked in every polling interval. If it returns true, the check is successful and the polling will stop. The first parameter passed into the function is the same value that gets passed to the success function. Returning something other than boolean in the check will not change the first parameter of success. |
|
success | function |
Will get invoked after the check function returns true. If there is no check function defined, it will be directly invoked. waitFor statements added in the success handler will be executed before previously added waitFor statements. |
|
errorMessage | string |
Will be displayed as an errorMessage depending on your unit test framework. Currently the only adapter for Opa is QUnit. This message is displayed there if Opa has reached its timeout but QUnit has not yet reached it. |