Search for answers or browse our knowledge base.
Testing the Debugging Tutorial
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
Prerequisites
This tutorial assumes you have completed the first 7 steps of the Debugging Tutorial.
Please complete the tutorial if you have not done so already, then return to this page in step 8 to learn how to test it.
Testing The Triggered Rule
Now that we have investigated the Rule and understand it better, it is time to write a few unit tests.
A Vantiq Test is driven by a
sequence of ordered input events and a expects a collection output events. Because Rules do not have return values, the test
requires an output event in order to ensure correctness.
Adding the PUBLISH to the end of the Rule creates the output event necessary to verify that the ageStatus and averageWeight were computed correctly.
We want to create a Test that
- INSERTS into the TutorialExampleType
- expects a PUBLISH to “/people/results” with correct ageStatus and averageWeight
Navigate to the TutorialExampleRule
Rule.
Edit the Rule and add the following code snippet to the last line at the bottom of the Rule:
PUBLISH {ageStatus: ageStatus, averageWeight: averageWeight} TO TOPIC "/people/results"
The PUBLISH we added in the Rule will allow us to use that event as an Output event so that we can test and ensure that
the Rule computed the right values.
Navigate back to the Autopsy pane for your successfully triggered Rule and click Create Test.
.
Type TutorialExampleRule0
as the testName and click OK.
A new Test pane will open with all of the General properties on the test already set.
Navigate to the Inputs
tab and verify that there is one input in the Inputs list.
The Test will expect 1 output: The PUBLISH to the /people/results
Topic performed by the Rule.
Navigate to the Outputs tab and click the Add Output Button.
The TutorialExampleType
Rule performs a PUBLISH on the /people/results
that includes the ageStatus
of the TutorialExampleType
and the averageWeight
of all TutorialExampleType
instances. The Test will pre-populate the Namespace with 3 instances of the
TutorialExampleType
(see below) so that the averageWeight is calculated over multiple instances of the Type.
Set topics as the Resource, /people/results as the ResourceId.
Click on the Click to Edit button to open the Event Object Editor and create a JSON Object with the following contents:
{
"ageStatus": "Adult",
"averageWeight": 126.25
}
Click OK to close the Event Object Editor.
As mentioned above, the test will pre-populate the Namespace withTutorialExampleType
instances.
Use the Add button in the IDE Navigation Bar to select Procedures and then click the New Procedure button to create a new Procedure.
Name the Procedure insertTutorialExampleType
. This Procedure is the Test Setup Procedure. The Procedure INSERTS
3 instances of the TutorialExampleType
Type.
Copy and paste the following into the new Procedure Pane:
PROCEDURE insertTutorialExampleType()
DELETE TutorialExampleType WHERE weight < 300
INSERT TutorialExampleType(age: 10, weight: 60)
INSERT TutorialExampleType(age: 20, weight: 120)
INSERT TutorialExampleType(age: 30, weight: 150)
Click Save to save the Procedure.
Use the Add button again to select Procedures and then click the New Procedure button to create a new Procedure.
Name the Procedure deleteTutorialExampleType
. This Procedure is the Cleanup Procedure. The Procedure DELETEs
all instances of the TutorialExampleType
that were INSERTED.
Copy and paste the following into the new Procedure Pane:
PROCEDURE deleteTutorialExampleType()
DELETE TutorialExampleType WHERE weight < 300
Click Save to save the Procedure.
The Test requires Setup and Cleanup Procedures. Navigate back to the Test pane in which we were defining the
TutorialExampleRule0
test and click on the General tab.
Select insertTutorialExampleType as the Setup Procedure and deleteTutorialExampleType as the Cleanup Procedure. Save the
Test.
Click the Show Test History button to watch the test run in real time when the Run Test button is clicked next.
Navigate back to the TutorialExampleRule
Rule. Select the new test TutorialExampleRule0
from the Execute droplist and then
click Run.
Wait for the Test History List to show one entry with a green check showing a successful test run.
Testing The Untriggered Rule
We want to now create a second Test that tests the case where the INSERT on the TutorialExampleType
Type has age < 5
which should not trigger the Rule.
Navigate back to the Autopsy pane for your untriggered Rule and click Create Test.
Name the test TutorialExampleRule1
and click OK.
A new Test pane opens with all of the General properties on the test already set.
Change the Timeout Time for the test to 10 seconds.
Navigate to the Inputs tab and verify that there is one input in the Inputs list.
Navigate to the Outputs Tab and click Add Output.
Set topics as the Resource, /people/results as the ResourceId.
Because the Rule should not be triggered, there should be no PUBLISHES to the /people/results Topic.
Set the Validation Method to Missing. This means that the Test expects no PUBLISHES on the /people/results Topic, and
if one is received within the Timeout Time period, the Test fails.
Navigate to the General tab.
Because the Rule is not triggered and the averageWeight is not calculated, a Setup Procedure is not required.
However, this Test performs an INSERT on the TutorialExampleType
Type which should be cleaned up.
Select deleteTutorialExampleType as the Cleanup Procedure. Save the Test.
Click on the Show History button to watch the test run in real time.
Navigate back to the TutorialExampleRule
Rule. Select the new test TutorialExampleRule1
from the Execute droplist and then
click Run.
Wait for the Test History List to show one entry with a green check showing a successful test run.
Running the Test Suite
Navigate to the Test Suite List by selecting Test Suites under the Test tab. There should be one entry called
TutorialExampleRule_UnitTestSuite
. This is the auto-generated Test Suite for all Unit Tests that test the TutorialExampleRule
.
This Test Suite will always keep itself up to date with all the Unit Tests that test this Rule.
Click on the Test Suite to open up the Test Suite Pane.
Navigate to the Tests tab to see the list of all the Tests for this Rule. You should see both Tests that you defined.
Click Run Test to run the Test Suite.
Click Show Test History and wait until a green check appears showing that the Test Suite has completed successfully.
This should take a little over 10 seconds since this is the timeout period.
Click on the report to see the breakdown of each test within the Test Suite.
Conclusion
Developers creating applications should now be able to effortlessly:
- Trace through parts of their code step-by-step to see how rules and procedures are functioning with sample input
- Create tests from autopsies of rules and procedures
- Create setup and cleanup Procedures for Tests
- Run a Test Suite
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
-
Getting Started
-
- Advanced Collaborations
- Analytics
- App Components
- Assemblies
- Catalogs Tutorial
- Client Builder
- Client Components
- Deployment Tutorial
- Floor Plan
- Introduction to Collaboration
- Natural Language Tutorial
- Sources
- Stateful Services
- System Modeler
- Testing the Debugging Tutorial
- Testing the Introductory Tutorial
- Testing the Source Tutorial
- User and Namespace Administration
- Show Remaining Articles ( 3 ) Collapse Articles
-
Product Documentation
-
-
-
- Accessing Documents
- Automatic Document Caching
- Client Resources
- Client Startup
- Control Widgets in the "Views" Portion of Client Builder
- Controllers
- Creating A Client
- Data Objects
- Data Stream Widgets in the “Views” Portion of Client Builder
- Data Streams
- Debugging
- Field Validation
- Introduction
- Launching Clients from a browser
- Layout Widgets in the “Views” Portion of Client Builder
- Localizing Clients
- Navigation Between Pages
- Offline Operation
- On Start Events
- Public Clients
- Server Requests
- Terminating The Client
- The Client Builder Concepts
- The Client Builder's Canvas Section
- The Client Builder's Control Dock
- The Client Builder's Palette Area
- The Client Builder's Slideout Section
- Uploading data to the Server
- Show Remaining Articles ( 13 ) Collapse Articles
-
- abort()
- cancelSpeaking()
- clearInterval()
- clearTimeout()
- clone()
- closePopup()
- confirmCustom()
- confirmCustomEx()
- createClientEventDataStream()
- createDataChangedDataStream()
- createOutboundServiceEventDataStream()
- createPagedQueryDataStream()
- createPublishEventDataStream()
- createResourceEventDataStream()
- createResponseObject()
- createSourceEventDataStream()
- createTimedQueryDataStream()
- data
- deleteOne()
- errorDialog()
- execute()
- executePublic()
- executeStreamed()
- executeStreamedPublic()
- formatMsg()
- generateUUID()
- getCollaborationContext()
- getCurrentPage()
- getCurrentPopup()
- getDataStreamByName()
- getDataStreamByUUID()
- getDeviceId()
- getDeviceName()
- getDocumentAssetLabelList()
- getDocumentAssetList()
- getDocumentUrl()
- getGroupNames()
- getLocation()
- getName()
- getProfileNames()
- getRequestParameters()
- getStateObject()
- getUsername()
- getUserRecord()
- getWidget()
- goToPage()
- infoDialog()
- insert()
- instance
- isNetworkActive
- isPublic
- localeCountryCode
- localeLanguageCode
- localeVariantCode
- logout()
- markupImage()
- modifyClientEvent()
- modifyDataChanged()
- modifyPagedQuery()
- modifyPublishEvent()
- modifyResourceEvent()
- modifyServiceEvent()
- modifySourceEvent()
- modifyTimedQuery()
- navBarBackgroundColor
- navBarForegroundColor
- navBarIcon
- navBarIconHeight
- navBarIconWidth
- navBarShowControls
- navBarTitle
- navBarTitleFontFamily
- navBarTitleFontSize
- navBarTitleFontWeight
- Show Remaining Articles ( 59 ) Collapse Articles
-
-
-
- Accessing Namespaces in the Organization
- Active Resource Control Center
- Adding a New User to an Organization
- Adding a New User to the Application Namespace
- Administrators' Concepts and Terminology
- Authorizing Users to Access the Application
- Creating a Developer Namespace for the Organization Administrator
- Creating a New Application Namespace
- Creating Resources for New Namespaces
- Custom User Invites
- Deploying the GenAI Flow Service Connector
- Developer Tasks
- Handling Administrators Leaving
- Related Configuration
- Removing Namespace Administrators
- Self-Administration Tasks
- System Administration Tasks
- Viewing Lists of Users
- Show Remaining Articles ( 3 ) Collapse Articles
-
- Deploy Results Tab
- Deploying the same application to different environments
- Deployment
- Deployment Tool - Introduction
- Environment
- Environment Tab
- Node
- Project Partitions
- Redeploy On A Failed Node
- Reliable Deployment
- Settings Tab
- The Graph View
- The Tree View
- Undeploy
- Update Partitions
- Verify Application After Deployment
- Show Remaining Articles ( 1 ) Collapse Articles
-
- CheckedInsert/CheckedUpsert Command
- Command Line Options
- Delete Command
- Execute Command
- Export Command
- Find Command
- Help Command
- Import Command
- Insert Command
- Installation - Prerequisites
- Installation - Profile
- List Command
- Load Command
- Recommend Command
- Run Command
- Select Command
- Stop Command
- The Vantiq Command Line Interface (CLI) - Overview
- Upsert Command
- Show Remaining Articles ( 4 ) Collapse Articles
-
- App Execution Dashboard
- App With Split Dashboard
- Dashboard Navigation Bar
- Deprecated Dashboards
- Event Processing Dashboard
- General Dashboard Behavior
- Getting Started with Grafana
- Grafana Usage
- Monitoring Namespaces with Grafana
- Most Commonly Used Dashboards
- Namespace Monitoring Dashboards
- Organization Level Behavior
- Procedure and Rule Execution Dashboards
- Profiling Dashboards
- Reliable Event Dashboard
- Resource Usage Dashboard
- Service Execution Dashboard
- Service Handler Dashboard
- Source Activity Dashboard
- Storage Manager Dashboard
- Tensorflow Model Dashboard
- Type Storage Dashboard
- Show Remaining Articles ( 7 ) Collapse Articles
-
- Access to a Kubernetes Cluster
- Creating a K8s Cluster
- Delayed Processing
- Deploying K8s Installations to a Kubernetes Cluster
- Deploying the K8s Worker
- External Lifecycle Management Guide - Overview
- K8s Worker
- Kubernetes Components of a K8s Installation
- Kubernetes Namespaces
- Loading Images into a Kubernetes Cluster
- Managing K8s Installations
- Other Configuration Options
- System View
- Use of the self Cluster
- Using a Kubernetes Cluster
- Using Templates to Deploy the K8s Worker
- Vantiq Namespaces
- Verify Installation
- Show Remaining Articles ( 3 ) Collapse Articles
-
- Changing the System Password
- Creating a GenAIFlowService Service Connector
- Creating a New Organization and Namespace
- Deployment Methods
- Docker Deployment
- Edge Installation Management
- Edge Vision Server
- Executable JAR Deployment
- MongoDB
- Requirements
- Running the Vantiq Executable
- Setting the default LLMs API key
- Setting Up Vantiq Edge
- Vantiq Edge Reference Guide - Overview
- Vantiq Edge Self Node
- Windows bat file
- Show Remaining Articles ( 1 ) Collapse Articles
-
- Additional Buffer Semantics
- Applicability
- auditFrequency Quota
- Background
- Default Quotas
- Detailed Credit Quotas
- errorBreaker Quota
- errorReportingFrequency Quota
- Execution Credit Quota
- Execution Credit Quota - Diagnostics
- Execution Credit Quota - Mitigation
- Execution Rate Quota
- Execution Rate Quota - Diagnostics
- Execution Rate Quota - Mitigations
- executionTime Quota
- k8sResources Quota
- Quota Interactions
- receiveMessage Quota
- receiveMessage Quota - Diagnostics
- receiveMessage Quota - Mitigation
- reservedGroups Quota
- stackDepth Quota
- Stream Quota
- Terminology
- Workload Management
- Workload Management Conceptual Model
- Show Remaining Articles ( 11 ) Collapse Articles
-
-
-
- Accumulate State
- Analytics
- Answer Question
- App Activity Tasks
- App Builder Guide - Introduction
- App Builder Overview
- Assign
- Build and Predict Path
- Cached Enrich
- Chat
- Close Collaboration
- Collaborations in Apps
- Compute Statistics
- Convert Coordinates
- Creating an App
- DBScan
- Delay
- Dependency Management
- Dwell
- Enrich
- Error Handling
- Escalate
- EscalateState
- Establish Collaboration
- Event Redelivery
- Event Stream
- Filter
- GenAI Flow
- Get Collaboration
- Interpret Conversational Language
- Join
- K-Means Cluster
- Limit
- Linear Regression
- Log Stream
- Loop While
- Merge
- Notify
- Optional Imports
- Polynomial Fitter
- Predict Paths By Age
- Procedure
- Process Intent
- PublishToService
- PublishToSource
- PublishToTopic
- Rate
- Recommend
- RecordEvent
- Reliable Apps
- Run TensorFlow Model On Document
- Run TensorFlow Model On Image
- Run TensorFlow Model On Tensors
- Sample
- SaveToType
- Split By Group
- Submit Prompt
- Threshold
- Time Difference
- Track
- Track Motion
- Tracking Progress
- Transformation
- Unwind
- VAIL
- VisionScript
- Window
- Within Tracking Region
- YOLO From Images
- Show Remaining Articles ( 54 ) Collapse Articles
-
-
-
- Broker Service
- Catalog Operations
- Catalog Procedures
- Connect to Catalog
- Create Entry
- Create Entry
- Custom Operations
- Disconnect from Catalog
- Host Catalog
- Integrating Applications With the Catalog
- Managing Catalog
- Managing Event Types
- Publisher Service
- Register
- Remove Entry
- Repair Catalog
- Resolve
- Subscriber Service
- Unhost Catalog
- Unregister
- Utilities
- Show Remaining Articles ( 6 ) Collapse Articles
-
-
-
- Advanced Use Cases
- Data Manipulation
- Defining Types
- Discovery from External Data Store
- Error Handling
- Installation and Use
- Native Language Implementation
- Restricting Capabilities
- Service Connectors
- Storage Manager Assembly Contents
- Storage Manager Service API
- Storage Manager Transactions
- Storage Managers - Introduction
- Transaction Support
-
-
-
- App Pane
- Autopsies
- Defining a Run Policy
- Defining a Test Suite - Properties
- Defining an Input
- Defining an Output
- Error Pane
- Integration Tests
- Populate Testing Namespace With Data
- Procedure Pane
- Rule Pane
- Running a Test in the IDE
- Running a Test through the REST Interface
- Source Mocking For Tests
- Unit Tests
- Vantiq Testing Reference Guide - Introduction
- Show Remaining Articles ( 1 ) Collapse Articles
-
-
-
- Assign
- Branch
- Categorize
- CodeBlock
- Consensus
- Content Ingestion Flows
- Conversation
- GenAI Builder Guide Introduction
- GenAI Builder Layout
- GenAI Components
- GenAI Flow Properties
- GenAI Flow Tracing and Auditing
- Launching the GenAI Builder
- LLM
- Memory and Conversations
- Merging Task Outputs
- NativeLCEL
- Optional
- PromptFromTemplate
- RAG
- Repeat
- Runtime Configuration
- Semantic Index
- Sub-Flows
- Supported VAIL Language Features
- Using GenAI Components
- Vantiq Provided GenAI Components
- Show Remaining Articles ( 12 ) Collapse Articles
-
- AWS
- Azure OpenAI
- Bedrock
- Configuration
- Function Authorizer
- Gemini
- LLM Playground
- Main Chatting Area
- Navigation Panel
- NVIDIA NIM
- OpenAI
- SageMaker
- Settings Panel
- Testing Semantic Index
- Tool Authorizer
- Tools
- Show Remaining Articles ( 1 ) Collapse Articles
-
-
-
-
- Assembly Configs
- Audits
- Catalog Members
- Catalogs
- Debug Configs
- Delegated Requests
- Documents
- Event Generators
- Groups
- Images
- K8s Clusters
- K8s Installations
- K8s Workitems
- LLMs
- Logs
- Namespaces
- Nodes
- Organizations
- Procedures
- Profiles
- Projects
- Resource Definition
- Resource Events
- Resource Relationship Model
- Resource Security Model
- Rules
- Scheduled Events
- Secrets
- Semantic Indexes
- Service Connectors
- Services
- Sources
- StorageManagers
- TensorFlowModels
- Test Reports
- Test Suites
- Tests
- Tokens
- Topics
- TrackingRegions
- Types
- Users
- Vantiq Resources
- Videos
- Show Remaining Articles ( 29 ) Collapse Articles
-
- Before Rules
- Built-In Services
- Data Manipulation
- Data Model Declarations
- Declaring Packages
- Defining Remote Connections
- Distributed Processing
- Error Handling
- Event Sending
- External State
- Flow Control
- General Use Procedures
- In-Memory State Management
- Iteration
- Logging
- Operators
- Package Scoping and Name Resolution
- Packages
- Packages
- Persistent State
- Procedure Execution
- Procedures
- PROCESSED BY Clause
- Resource Definition
- RETURN
- Rules
- Services
- Syntax
- Type Specific Procedures
- VAIL Declarations
- VAIL Types
- Variables
- Show Remaining Articles ( 17 ) Collapse Articles
-
-
-
Articles
-
- How To Video Shorts: Client Layouts
- How To Video Shorts: AI Functions
- How To Video Shorts: Analytics and ComputeStatistics
- How To Video Shorts: Calling Procedures by Properties
- How To Video Shorts: Client CSS
- How To Video Shorts: Invite Other Users to Your Namespace
- How To Video Shorts: SplitByGroup
- How To Video Shorts: The Vantiq API
- How To Video Shorts: The Vantiq IDE
- How To Video Shorts: The Vantiq Version Control System
- How To Video Shorts: Using Generative AI in Applications
- How-To Video Shorts: Managing AI Conversations
- How-To Videos: AI Design Model Assistant
- How-To Videos: AI Documentation Search
- Production Applications Best Practices