|
|
|
|
|
- Overview
- The assertions
- Implementation
- Tip
- Customizing the window of assertions
WINDEV, WEBDEV and WINDEV Mobile include several tools and features used to optimize the applications and the sites. The main available features are as follows: An assertion is used to check a condition when running the application. If the condition fails, a dialog box containing the check details is displayed. The developer can access the runtime stack, which means all calls that resulted in this result. To define an assertion, simply use dbgAssert with the following parameters: - the condition to check,
- the message to display if the condition is not checked.
// CClient variable clClient is CClient // Create the client CreateClient(clClient) // The clClient object must have been instantiated dbgAssert(clClient<>Null, "The object was not instantiated")
By default, the assertions are enabled in test mode only. The assertions can be enabled in deployment: simply use dbgEnableAssert:
Caution: The condition used in the assertion is run by WLanguage only when the assertions are enabled. Therefore, the operating mode may differ in test mode and in executable mode. You must be very careful when using functions in the condition given to dbgAssert. Indeed, if the function used performs an initialization or a connection, this operation will not be performed in the application used in "executable" mode. On the other hand, this operating mode allows you to run "more tests" without slowing down the deployed application. This gives you the ability to easily enhance the applications. Tip Assertions can be used to run "specific" cases or to check the "prerequisites" of a function. This allows you to check the case that should never happen: - using an empty string while a logical name is expected,
- entering a path to a file that does not exist, ...
The assertions cannot replace the standard management of errors. But implementing an assertion allows you to be informed and to find out whether a problem occurred via the execution stack. The assertions are also used to guide you when the development is performed by several developers: the "calling" code must provoke no assertion in the code that is "called".
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|