@@ -125,17 +125,32 @@ For details on contributions we accept and the process for contributing, see our
125125
126126From the ` test ` directory, execute the ` run_tests.sh ` script.
127127
128+ ### Dependencies
129+
130+ ` bash ` - the tests scripts are written in ` bash ` syntax
131+ ` valgrind ` - required to identify and protect against memory leaks.
132+
128133### Success
129134
130- Upon success, you will see the following message :
135+ Upon success, you will see a message similar to the following:
131136
132137``` none
133138...
134- [passed] test_notecard_debugSyncStatus_does_not_modify_note_c_result_value_before_returning_to_caller
135- [passed] test_notecard_responseError_does_not_modify_j_object_parameter_value_before_passing_to_note_c
136- [passed] test_notecard_responseError_does_not_modify_note_c_result_value_before_returning_to_caller
137-
138- All tests passed!
139+ [passed] test_noteserial_arduino_transmit_invokes_hardware_serial_flush_when_flush_parameter_is_true
140+ [passed] test_noteserial_arduino_transmit_does_not_invoke_hardware_serial_flush_when_flush_parameter_is_false
141+ [passed] test_noteserial_arduino_transmit_does_not_modify_hardware_serial_write_result_value_before_returning_to_caller
142+ ==13467==
143+ ==13467== HEAP SUMMARY:
144+ ==13467== in use at exit: 0 bytes in 0 blocks
145+ ==13467== total heap usage: 2 allocs, 2 frees, 73,728 bytes allocated
146+ ==13467==
147+ ==13467== All heap blocks were freed -- no leaks are possible
148+ ==13467==
149+ ==13467== For lists of detected and suppressed errors, rerun with: -s
150+ ==13467== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
151+ NoteSerial_Arduino tests passed!
152+
153+ All tests have passed!
139154```
140155
141156### Failure
@@ -144,34 +159,48 @@ When a test fails, you will see a message similar to the following:
144159
145160``` none
146161...
147- [passed] test_notecard_sendRequest_does_not_modify_j_object_parameter_value_before_passing_to_note_c
148- [passed] test_notecard_sendRequest_does_not_modify_note_c_result_value_before_returning_to_caller
149- [FAILED] test_notecard_requestAndResponse_does_not_modify_j_object_parameter_value_before_passing_to_note_c
150-
151- Test <27> failed!
162+ [passed] test_notei2c_arduino_constructor_invokes_twowire_parameter_begin_method
163+ [passed] test_notei2c_arduino_receive_requests_response_data_from_notecard
164+ [FAILED] NoteI2c_Arduino.test.cpp:120
165+ twoWireBeginTransmission_Parameters.invoked == 2, EXPECTED: > 1
166+ twoWireWriteByte_Parameters.invoked == 4, EXPECTED: > 2
167+ twoWireEndTransmission_Parameters.invoked == 2, EXPECTED: > 1
168+ [FAILED] test_notei2c_arduino_receive_will_retry_transmission_on_i2c_failure
169+ ==14566==
170+ ==14566== HEAP SUMMARY:
171+ ==14566== in use at exit: 0 bytes in 0 blocks
172+ ==14566== total heap usage: 7 allocs, 7 frees, 73,738 bytes allocated
173+ ==14566==
174+ ==14566== All heap blocks were freed -- no leaks are possible
175+ ==14566==
176+ ==14566== For lists of detected and suppressed errors, rerun with: -s
177+ ==14566== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
178+ NoteI2c_Arduino tests failed!
179+
180+ TESTS FAILED!!!
152181```
153182
154183Here, the failed test is the last reported test,
155- ` test_notecard_requestAndResponse_does_not_modify_j_object_parameter_value_before_passing_to_note_c ` ,
156- and the related test number is ` 27 ` . The return value of each test is unique,
157- therefore this number can be used to find the test in ` notecard- test.cpp` by
158- searching for " ` result = 27 ` " .
184+ ` test_notei2c_arduino_receive_will_retry_transmission_on_i2c_failure ` . The first
185+ line marked with ` [FAILED] ` indicates the file and line number related to the
186+ failed test: file ` NoteI2c_Arduino. test.cpp` near line ` 120 ` . The return value
187+ of each test is a non-zero identifier related to the test suite .
159188
160189### Adding a New Test
161190
162191The signature of a test function is ` int(*test_fn)(void) ` , so to say, a test
163192function takes NO parameters and returns an integer.
164193
165- To add a new test to ` notecard-test.cpp ` , add your new test immediately below
166- the last test and increment the error value, ` result ` , by 1. At the time of
167- writing, the last test returns an error value of 36, therefore the error
168- condition of a new test should set the ` result ` value to 37.
194+ To add a new test to a test suite, create your new test and add the test
195+ to the test runner at the bottom of the file. You may find it easiest to copy
196+ an existing test and adapt the ** Arrange** , ** Action** , and ** Assert** sections.
197+ Please create an expressive error message that can assist in understanding a
198+ failed test.
169199
170- To add this test to the runner, copy the test's name and use it to create an
171- entry in the ` tests ` array in the ` main ` function. The entry will occupy it's
172- own line at the end of the array, and syntax should be as follows,
173- ` {test_name, "test_name"} ` . _ Don't forget to add a comma to the end of the
174- array, before adding your new entry._
200+ To add a test to the runner, copy the test's name and use it to create an entry
201+ in the ` tests ` array in the ` main ` function. The entry will occupy it's own line
202+ at the end of the array, and syntax should be as follows,
203+ ` {test_name, "test_name"}, ` .
175204
176205## More Information
177206
0 commit comments