
One Method to Test Them All
I counted Ginkgo's top-level API once. Describe , Context , When , It , Specify , By , BeforeEach , AfterEach , BeforeAll , AfterAll , JustBeforeEach , JustAfterEach , BeforeSuite , AfterSuite , SynchronizedBeforeSuite , SynchronizedAfterSuite , DeferCleanup . That's 17, and I stopped counting. There are more if you include the F and P prefixed variants for focus and pending. GoConvey is leaner but still has Convey , So , ShouldEqual , SkipConvey , FocusConvey , Reset , and its own assertion DSL. I kept asking myself: what's the minimum API a scoped testing framework actually needs? Not "what's nice to have" -- what's the floor? Turns out it's one method. The entire API s . Test ( "name" , fn ) // leaf test s . Test ( "name" , fn , builder ) // parent with children s . Skip () // skip this scope That's samurai . The full public surface fits on a napkin: func Run ( t * testing . T , builder func ( * Scope ), opts ... Option ) func RunWith [ V Context ]( t , factory , builder , opts ...
Continue reading on Dev.to
Opens in a new tab


