The test monitor panel reports self-test results to the Arduino programming visualizer. Self-tests are typically used during manufacturing of custom devices for functional testing. Functional testing checks if all of the components on the board are operating correctly.
This page describes the methods implemented by the TestResult
class in the MegunoLink Arduino library to report results to a test-monitor panel. Refer to Arduino programming for documentation on the visualizer.
To use the TestReport
, create a variable and call one of the methods below. For example:
1 2 3 4 5 6 7 8 9 |
#include "MegunoLink.h" void DoTest() { TestReport TestResult; bool bTestResult = CheckSensor(); TestResult.ReportResult("Sensor", bTestResult); } |
Methods
Test reports are a pass/fail with an optional data value. The data value is included in the test report shown in MegunoLink and may provide additional insights or information about the test result.
Tests can be matched by a numeric id or by name in MegunoLink. Using a numeric id may be more robust if the name of the test could change.
The following methods are available for a TestReport
:
TestReport(Print &Destination);
StartingTest();
TestComplete();
ReportResult(int TestId, bool Pass);
ReportResult(int TestId, bool Pass, TData Data);
ReportResult(const char *Name, bool Pass);
ReportResult(const __FlashStringHelper *Name, bool Pass);
ReportResult(const char *Name, bool Pass, TData Data);
ReportResult(const __FlashStringHelper *Name, bool Pass, TData Data);
Pass(const char *Name);
Pass(const __FlashStringHelper *Name);
Pass(const char *Name, TData Data);
Pass(const __FlashStringHelper *Name, TData Data);
Fail(const char *Name);
Fail(const __FlashStringHelper *Name);
Fail(const char *Name, TData Data);
Fail(const __FlashStringHelper *Name, TData Data);
Method Descriptions
Test Report Constructor
Creates a TestReport
variable, which can be used to send commands to MegunoLink to record the results from tests.
TestReport(Print &Destination = Serial);
Name | Type | Required? | Description |
---|---|---|---|
Destination | Print & | No | Sets the serial connection to use for sending messages to MegunoLink. Defaults to Serial , the default Arduino RS232 port. |
1 2 3 4 |
#include "MegunoLink.h" TestReport TestReport1; TestReport TestReport2(Serial1); // send messages to Serial1 port. |
StartingTest
Informs MegunoLink that a test is about to start. MegunoLink resets all test results to unknown and starts waiting for test results.
void StartingTest();
1 2 3 4 5 6 7 8 |
void DoTest() { TestReport TestReport1; TestReport1.StartingTest(); // Prepare MegunoLink for a new test TestReport1.ReportResult("Battery", IsBatteryOk()); // Send some test results TestReport1.TestComplete(); // Test is done. } |
TestComplete
Informs MegunoLink that all the test results have been sent. MegunoLink reports the overall test result and continues with the next step in the programming sequence (if any).
void TestComplete();
1 2 3 4 5 6 7 8 |
void DoTest() { TestReport TestReport1; TestReport1.StartingTest(); // Prepare MegunoLink for a new test TestReport1.ReportResult("Battery", IsBatteryOk()); // Send some test results TestReport1.TestComplete(); // Test is done. } |
Report Result using a TestId
Sends the outcome of a test to MegunoLink. The test result reported is identified by the TestId
in MegunoLink. The outcome is either pass or fail. Data, providing additional information about the test result, may be optionally included. This data is displayed for the user in the test result panel.
void ReportResult(int TestId, bool Pass);
void ReportResult(int TestId, bool Pass, TData Data);
Name | Type | Required? | Description |
---|---|---|---|
TestId | int | Yes | The id of the test to match in MegunoLink. |
Pass | bool | Yes | Outcome of the test. True indicates the test passed; false indicates it failed. |
Data | TData | No | Additional data to include in the test report. Any data type supported by the Arduino print method may be used. |
1 2 3 4 5 6 7 8 9 10 11 |
void DoTest() { TestReport TestReport1; const int TestId_SensorTest = 1; const int TestId_BatteryTest = 2; TestReport1.StartingTest(); TestReport1.ReportResult(TestId_BatteryTest, IsBatteryOk(), GetBatteryVoltage()); TestReport1.ReportResult(TestId_SensorTest, IsSensorOk()); TestReport1.TestComplete(); } |
Report Result using a Test Name
Sends the outcome of a test to MegunoLink. The test result reported is identified by name in MegunoLink. The outcome is either pass or fail. Data, providing additional information about the test result, may be optionally included. This data is displayed for the user in the test result panel.
void ReportResult(const char *Name, bool Pass);
void ReportResult(const char *Name, bool Pass, TData Data);
void ReportResult(const __FlashStringHelper *Name, bool Pass);
void ReportResult(const __FlashStringHelper *Name, bool Pass, TData Data);
Name | Type | Required? | Description |
---|---|---|---|
Name | const char *, const __FlashStringHelper | Yes | The name of the test to match in MegunoLink. |
Pass | bool | Yes | Outcome of the test. True indicates the test passed; false indicates it failed. |
Data | TData | No | Additional data to include in the test report. Any data type supported by the Arduino print method may be used. |
1 2 3 4 5 6 7 8 9 10 |
void DoTest() { TestReport TestReport1; TestReport1.StartingTest(); TestReport1.ReportResult("Power Supply", IsBatteryOk(), GetBatteryVoltage()); TestReport1.ReportResult(F("Sensor 1"), IsSensor1Ok()); TestReport1.ReportResult(F("Sensor 2"), IsSensor2Ok()); TestReport1.TestComplete(); } |
Report a Passing Test Result
Sends a passing test result to MegunoLink. Data, providing additional information about the test result, may be optionally included. This data is displayed for the user in the test result panel.
void Pass(const char *Name);
void Pass(const char *Name, TData Data);
void Pass(const __FlashStringHelper *Name);
void Pass(const __FlashStringHelper *Name, TData Data);
Name | Type | Required? | Description |
---|---|---|---|
Name | const char *, const __FlashStringHelper | Yes | The name of the test to match in MegunoLink. |
Data | TData | No | Additional data to include in the test report. Any data type supported by the Arduino print method may be used. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
void DoTest() { TestReport TestReport1; TestReport1.StartingTest(); int Voltage = GetBatteryVoltage(); if (Voltage > 3000) { TestReport1.Pass("Power Supply", Voltage); } else { TestReport1.Fail("Power Supply", Voltage); } TestReport1.TestComplete(); } |
Report a Failing Test Result
Sends a failing test result to MegunoLink. Data, providing additional information about the test result, may be optionally included. This data is displayed for the user in the test result panel.
void Fail(const char *Name);
void Fail(const char *Name, TData Data);
void Fail(const __FlashStringHelper *Name);
void Fail(const __FlashStringHelper *Name, TData Data);
Name | Type | Required? | Description |
---|---|---|---|
Name | const char *, const __FlashStringHelper | Yes | The name of the test to match in MegunoLink. |
Data | TData | No | Additional data to include in the test report. Any data type supported by the Arduino print method may be used. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
void DoTest() { TestReport TestReport1; TestReport1.StartingTest(); int Voltage = GetBatteryVoltage(); if (Voltage > 3000) { TestReport1.Pass("Power Supply", Voltage); } else { TestReport1.Fail("Power Supply", Voltage); } TestReport1.TestComplete(); } |