Skip to content

Commit 8ca91e1

Browse files
committed
Added example of test comments, teardown, and proper ordering in method name
1 parent 9697d61 commit 8ca91e1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,14 @@ However, *DO NOT* be afraid to say, "that looks terrible", and tweak it until it
122122
7. Use "real" names for data in test data set. Either use actual real location/project/basin/etc names, or make up something that feels like one.
123123
a. NOTE: within reason. Location names, absolutely, but otherwise make sure the purpose of the name is clear.
124124
8. Name files consistent with the purpose of the test.
125-
9. Narrative tests: Test method names should be a narrative summary of the test. For example, `test_stream_create_then_update_then_delete_success(...)`. <br>
125+
9. Narrative tests: Test method names should be a narrative summary of the test. For example, `test_stream_create_then_update_then_delete_success()`. <br>
126126
a. Use underscores to make the narrative structure of the test name clear.<br>
127-
b. The method name should be a clear summary of what is being tested (create, get, update, delete) in order of operations.<br>
127+
b. The method name should be a clear summary of what is being tested (create, get, update, delete) in order of operations. Not how the above example follows this with use of <i>then</i><br>
128128
c. It should also include the expected result (success, error code, etc.)<br>
129-
d. Comments should also be used in narrative flow to clarify the details of the test internally, but not as a substitute for a clear method name.<br>
129+
d. Comments should also be used in narrative flow to clarify the details of the test internally, but not as a substitute for a clear method name. (example: [StreamControllerTestIT comments](https://github.com/USACE/cwms-data-api/blob/a1d265372ead2db0123b74ff0ffa6c76a7e21949/cwms-data-api/src/test/java/cwms/cda/api/StreamControllerTestIT.java#L124)<br>
130130
e. Setup and tear down methods should also be clearly labelled as such. Setup/teardown methods should call into well-named helper methods to clarify the purpose of the setup/teardown steps.<br>
131-
(example: setup method calls helper method `create_test_location()` followed by `create_test_time_series()` to clarify the purpose of the setup step)<br>
131+
(example: setup method calls helper method `create_test_location()` followed by `create_test_time_series()` to clarify the purpose of the setup step<br>
132+
likewise, the tear down method calls helper method `delete_test_time_series()` followed by `delete_test_location()` to clarify the purpose of the tear down step)<br>
132133

133134

134135

0 commit comments

Comments
 (0)