Skip to content

Commit

Permalink
Rewrite SerializationContextTest to avoid using mocks.
Browse files Browse the repository at this point in the history
The current approach of mocking `CodedOutputStream` is dubious because we are verifying calls to `final` methods. In this case, Mockito does not actually verify the specified method call, but instead verifies calls to the methods called within the body of the specified method.

It's not too hard to use real instances for `CodedOutputStream` and `ObjectCodecRegistry` in this test, which is generally better than mocks anyway.

PiperOrigin-RevId: 404089580
justinhorvitz authored and copybara-github committed Oct 18, 2021
1 parent 6c73a2e commit 406fc1b
Showing 2 changed files with 132 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -24,11 +24,13 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:build_java_proto",
"//third_party:auto_value",
"//third_party:guava",
"//third_party:junit4",
"//third_party:mockito",
"//third_party:truth",
"//third_party/protobuf:protobuf_java",
"@com_google_testparameterinjector//:testparameterinjector",
],
)

Loading

0 comments on commit 406fc1b

Please sign in to comment.