Improving databases tests

As a developer, you’re aware that improving the quality of your developments is often based on unit tests. In order to launch these tests, developers and QA teams need tools to launch 4D databases in different modes (single user / client-server) and distinct environments (Macintosh / Windows).

4D products can already be launched using command line parameters to allow automatic testing or deployment. What if you want to create your own update mechanism or you need to handle a server farm with hundreds of 4D Servers running? Maybe you want to specify which database file to use – or pass parameters on launch …

Reminder

The command line can be used the same way on both macOS and Windows. 

The simplified syntax looks like this:  App + structure + data

4D Application --structure <path to structure file> --data <path to data file>

New in 4D V17 R3

With 4D v17 R3, new parameters have been added to give you more flexibility when opening your databases:

  • –opening-mode: will specify to open your database in interpreted or compiled mode
  • –create-data: will create new data if the current data file is not found or with a specific name if – –data is passed!
  • –user-param: will send a string that can be read after the database is launched using the GET DATABASE PARAMETER command (detailed below)

 

GET / SET DATABASE PARAMETER 

It’s now possible to set a database parameter of text type that can be retrieved once the database has been relaunched with the RESTART 4DOPEN DATA FILE, or OPEN DATABASE command. This will avoid writing and reading temporary files on disk, as well as make your work easier and efficient.

SET DATABASE PARAMETER(User param value;$userParam)

After restarting the database, the $userParam can be read the same way:

$result:=Get database parameter(User param value;$userParam)

4DLINK

Note that the user param can also be set inside the 4DLINK file!
If you want to know more about 4DLINKS, see the documentation here.

<database_shortcut structure_opening_mode="1"
structure_file="file:///Users/Mike/Orda.4dbase.4DB"
data_file="file:///Users/Mike/Orda.4dbase.4DD"
user_param="check"/>

 

HDI: Relaunch and Test 

For more details, check out the documentation.

Happy testing!

Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.