---
title: "Schedule Automated Tests with Quality Inspector"
app: "Quality Inspector"
section: "Set up"
last_updated: "2025-03-12"
url: "https://insight-works.com/kb/quality-inspector/schedule-tests-automatically-with-quality-inspector/"
---

# Schedule Automated Tests with Quality Inspector

This example reviews how to schedule tests automatically. Create a work center test that runs automatically every morning. For your setup, configure the information to suit your needs.

### Ensure you have a source configuration for the required record

1. Navigate to _Quality Inspector Source Configuration List_ in Business Central.
2. Select **New**and modify the following fields in the _General_ section:

   - Code: WORKCENTER
   - Description: Work Center Example
   - State: Enabled
   - From Table: Work Center
3. Modify the fields in the _What Information Should be Added to the Test_section:

   - From Field Name: No.
   - To Field Name: Document No.

Now you can use the work center as a record to create your tests.

### Create a Quality Inspection Template to use for automated tests

 Note: The following is for a simple work center test; you can create more complex tests as needed.

1. Navigate to _Test Templates_ in Business Central.
2. Select **New** and modify the following fields in the _General_ section:

   - Code: EXAMPLE
   - Description: 5S Work Center Example
3. Select **Add Field(s) To This Template** and select **Next**.
4. Modify the following fields:

   - Description: Have unnecessary items in your workspace been removed? (Press **Enter** after inserting.)
   - Short name (Field Code): (auto populates with “HAVEUNNECESSARYITEMS”)
   - What type of data is it?: A choice from a list
5. Select **Next**.
6. Input “YES” on the first line and “NO” on the second line in the _Code _field.
7. Select **Finish**.
8. Select **Add Field(s) To This Template** and select **Next**.
9. Modify the following fields:

   - Description: Are tools, materials, and equipment arranged for a good workflow? (Press **Enter** after inserting.)
   - Short name (Field Code): (auto populates with “RETOOLSMATERIALSANDE”)
   - What type of data is it?: A choice from a list
10. Select **Next**.
11. Input “YES” on the first line and “NO” on the second line in the _Code _field.
12. Select **Finish**.
13. Select **Test Generation Rules**.
14. Select the _Table_field, select “Work Center”, and select **OK**.

 Note: To create different tests for different work centers. Select the ![](/wp-content/uploads/kb-legacy/icon.png) icon in the _Condition Filter_ field, modify the fields as needed, and select **OK**.

### Verify the test code and publish the code unit

To use the code example below, you need the following pre-requisite:

- A Quality Inspector Source configuration record for the work center (if you do not have one).
- A Quality Inspection Template with the metrics you would like to collect.
- A Quality Inspection Test Generation Rule that tells the system which Quality Inspection Template you want to use in which circumstances.

Review the test’s code with this [example](https://dev.azure.com/InsightWorks/External%20Examples/_git/Quality%20Inspector%20Examples?path=/CreateWithJobQueue). The codeunit that does the work is described like this:

```
codeunit 50700 "Example-Create Test Job Queue"

{

    Description = 'Example - Create a test with a job queue.';

    TableNo = "Job Queue Entry";

    trigger OnRun()

    var

        lrecWorkCenter: record "Work Center";

        lcuIWXQICreateTest: Codeunit "IWX QI Create Test";

        lrrefCreateTestOnRecordRef: RecordRef;

    begin

        // Step 1 : find the record you want to create your test with.

        //          in this example we're using a work center for the intent of a 5S test.

        //          If you are testing this example or altering it then you would use your own

        //          logic to find the record you wanted.

        //          We're using the 'Parameter string' field to define which work center we want.

        //          For example, if your work center was called 'QUALITY INSPECTION' that you wanted

        //          to create your 5S test with then in your job queue entry configuration you would put in the

        //          name of the work center there.

        if not lrecWorkCenter.Get(copystr(Rec."Parameter String", 1, maxstrlen(lrecWorkCenter."No."} then

            error('This example uses the Parameter String field on the Job Queue Entry card to determine which work center you want to use. Please configure the Parameter String there.');

        lrrefCreateTestOnRecordRef.GetTable(lrecWorkCenter);

        // Step 2 : create the test.  This would require you to have a test generation rule configured.

        //          'false' for the second parameter tells the system this test was created manually by hand.

        //          'true' for the second parameter tells the system this test was created automatically.

        //          This can be used to work with the 'show test' configuration option on the Quality Inspector Setup record.

        lcuIWXQICreateTest.CreateTest(lrrefCreateTestOnRecordRef, true);

    end;

}
```

Once you have the pre-requisite configuration and have published your codeunit, you can create a Job Queue Entry to schedule a test using that codeunit.

### Configure the test schedule and run the test

1. Navigate to _Job Queue Entries_ in Business Central.
2. Select **New**.
3. Modify the following fields:

   - Object Type to Run: Codeunit
   - Object ID to Run: 50700 (the codeunit we created)
   - Parameter String: 100
4. Modify the _Recurrence _section as needed (e.g., Run on Tuesdays with 7:00:00 AM Starting Time)
5. Select **Run once (foreground)** and select **Yes **to test.
6. Select **OK** and view the created test.

Note: If the test generates unexpected results (e.g., missing information), navigate to the _Quality Inspector Setup _page and set the following:

- Create Test Behavior: Always Create a New Test
- Find Existing Behavior: Standard Source Fields

Rerun the test once these are configured.

1. Select **Set Status to Ready**.
2. Select **Log Entries** (if test has run) to view the successful test run.

 Note: To view already run tests, navigate to the _Quality Inspection Tests_ page. Select a test to view the specific details if needed.

### Video

The following video goes through the process of scheduling automated tests with Quality Inspector.

[Video: Automate Work Center Tests in Business Central Using Job Queues](https://www.youtube.com/watch?v=r1Nqe8g7DBA)
