Associating a schema with MongoDB

After you establish the connection between HCL® OneTest Data and MongoDB, you must associate a schema with a database of MongoDB. You must select the schema that you want to use to generate the test data.

Before you begin

You must have created a collection in the selected MongoDB database.

For more information, refer to db.createCollection() section of Database Methods.

About this task

You can associate any schema with the MongoDB database that can generate the test data in the JSON format.

The following schema formats support the output format in JSON:

  • Excel
  • JDBC
  • XSD
  • CSV

Procedure

  1. Log in to HCL OneTest Server and open the team space that contains your project.
  2. Open your project.
    The Overview page is displayed.
  3. Click Author > Data Fabrication.
    The Data Fabrication page is displayed.
  4. Click the Connections tab and select the MongoDB connection name that you created.
  5. Click the menu and select New Action.
  6. Select Target as the Action Type in the New Action dialog, and then click Next.
  7. Click Fetch to extract a list of all the collections of the selected database, and then select a collection from the Collection drop-down list.
    Note:

    You can retain the default property settings for all other boxes.

  8. Click Next to provide the schema details.
  9. Click the Schema drop-down list to select the schema that you want to use to generate the test data.
  10. Click the Schema Type drop-down list to select the group type for which you want to generate the test data, and then click Next.
  11. Provide the identification details of the new action, and then click OK.

    The new action is created and listed under the MongoDB connection.

Results

You have successfully associated the schema with the database.

Tip: If you want to associate any other schema in the same database, then you must click New Action on the existing MongoDB connection. You need not create a new connection.

What to do next

You can generate the test data from the schema that you associated with the database of MongoDB. The generated test data is directly inserted into the database. See Inserting the generated test data in a database.