Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Mocktender – Tool to simplify testing (github.com/nizarmah)
4 points by nizarmah 8 months ago | hide | past | favorite | 2 comments
I built a tool that traces code behavior and isolates fixtures.

Eg. traditionally, I need 3 tests for HN's “submit post” (server route, handler logic, DB query). With this tool, I need only 1 (entry-point aka server route).

This tool traces the behavior across the layers, and isolates them to match traditional tests.

It’s in early proof-of-concept stage, dogfooding, with a working example.

It has a long way to go, so I'd love feedback/contributions—especially on a subject like testing.



That's a great idea! How does it work in reality? Also, what guarantees test correctness? How is it different from end-to-end tests?


1. I'm not sure if the question targets implementation or behavior. Briefly:

    a. Behavior: it automatically mocks functions that are called from a different layer (eg. route handler, repository method) so you don't need to maintain such tests or mocks yourself.
    b. Implementation: it transforms your codebase during testing by wrapping function implementations with a tracer or a mocker, depending on whether you're recording the behaviors or replaying/simulating them.
2. You still need to correctly test your entry-points' behavior. But here's the benefit this tool adds to "test correctness":

    a. You no longer maintain mocks/stubs yourself, which often become outdated and inaccurate. Instead, their values are computed in real time. And mocks/stubs are validated just like any other function.
    b. During tracing locally, it's your entire actual codebase running. The setup can be as close to production as possible. 
    c. During replaying in CI, you don't need to worry about the integrations. Some integrations you'll test by adding a setup/teardown for them. The rest, you can just review their cached behavior in version control.
3. It's simulated:

    a. The tracing/recording, which happens locally, runs identically to an end-to-end test.
    b. Meanwhile, replays, whether locally or in CI, simulate the end-to-end tests through isolated unit tests and integration tests.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: