catapult-project / catapult

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..
https://chromium.googlesource.com/catapult
BSD 3-Clause "New" or "Revised" License
1.93k stars 563 forks source link

Add a mocking framework #3407

Open chromy opened 7 years ago

chromy commented 7 years ago

I am several yaks deep and would like a mocking framework for a test in tracing. I suggest http://sinonjs.org/ since it is actively maintained and has some documentation.

chromy commented 7 years ago

https://codereview.chromium.org/2760473002/

eakuefner commented 7 years ago

I came to @natduca talking about this just yesterday, and the conclusion was that for the most part, we should see if we can solve these sorts of testing problems without mocking. Can you say more about your use case?

chromy commented 7 years ago

Great minds ;)

I have two objects A and B, I want to test A. A calls methods on B and uses the results to construct some value objects. B is a complicated thing in its own right which takes input and processes it to create the output that A uses. Constructing B in the test, while possible, will just obscure the details of B that A relies on while also making it possible to break the A test while making changes to B that don't effect A.

Both A and B are POJsO which we control.

(In this case A is tracing/tracing/extras/importer/heap_dump_trace_event_importer.html and B is tracing/tracing/extras/importer/streaming_event_expander.html in this half written patch: https://codereview.chromium.org/2635023002/)