Skip to content

separating startup and logic phases #1

@tbg

Description

@tbg

I was playing with this on https://github.com/cockroachdb/cockroach (more concretely (cd storage; discover test TestStoreSend)). It works fine, but since these tests have to actually start a server, there's a lot of code being run that isn't actually "logic".
I suspect that that's often going to be the case for complicated systems, and that the high level view is really where you'd want to use this tool most (as opposed to looking at a focused unit test, where reading the logic is easier).

So maybe this is crazy, but is there a way of setting "checkpoints" in tests that separate the setup- and logic phase? Something like

func TestSomething(t *testing.T) {
   setupServer()
   defer teardownServer()
   discover.Breakpoint()
   // do actual stuff; `discover` really only looks at what happens now
   discover.Teardown()
}

Maybe this could be achieved naively by running the test multiple times, panicking first at the first breakpoint, then at the second (and so on), and computing diffs from the accumulated coverage profiles?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions