Testing

Test qqq applications effectively

Overview

qqq applications are testable at multiple levels: unit tests for individual components, integration tests for workflows, and end-to-end tests for full scenarios.

Unit Testing

Test individual steps and actions:

Java
@Test
void testValidateOrderStep() {
    QInstance qInstance = TestUtils.defineInstance();
    RunBackendStepInput input = new RunBackendStepInput();
    input.addValue("orderId", 123);
    
    RunBackendStepOutput output = new ValidateOrderStep().run(input);
    
    assertTrue(output.getRecords().get(0).getValue("isValid"));
}

Integration Testing

Test complete processes:

Java
@Test
void testApproveOrderProcess() {
    QInstance qInstance = TestUtils.defineInstance();
    
    RunProcessInput input = new RunProcessInput();
    input.setProcessName("approveOrder");
    input.addValue("orderId", 123);
    
    RunProcessOutput output = new RunProcessAction().execute(input);
    
    assertEquals("APPROVED", output.getValue("status"));
}

Test Utilities

qqq provides testing utilities:

  • TestUtils - Instance setup helpers
  • MemoryBackend - In-memory data store
  • MockAuthentication - Test auth contexts
  • Test Data

    Manage test data with fixtures:

    Java
    @BeforeEach
    void setUp() {
        TestUtils.insertRecords(qInstance, "order", List.of(
            new QRecord().withValue("id", 1).withValue("status", "PENDING")
        ));
    }

    Coverage

    Aim for high coverage of business logic in processes and custom actions.

    Next Steps

  • Deployment - Deploy tested code
  • Powered by qqq