5 ms·
It's a cool idea, but I am struggling to understand why this is better than say BDD; which not only effectively documents what your code does but also verifies
by quii 14y ago
It's a cool idea, but I am struggling to understand why this is better than say BDD; which not only effectively documents what your code does but also verifies it does what it says it should do.
- chrisdevereux 14y agoThat was my though too. Are there any languages that let you write specs inline with the functions/classes that they test? That would be cool. Edit: Having thought about it for a second, this could easily be done in most languages (with some preprocessing to strip out for deployment. Super easy in C-based languages). Not a convention I see anyone follow, though.
- phpnode 14y agoi'm working on a project that does this with doc comments. Basically you add a doc block like this: ### @it should return true expect(foo()).to.be.true ### foo = -> true and the preprocessor extracts the test from the comment and associates it with the foo declaration.
- tomjen3 14y agoBecause BDD is too limited. It allows you only to state what should happen, not how or why. Like the comments newbies sometimes make in code //Assign 0 to i i = 0; Whereas with literate programming you can explain why you went with a particular style of code, why you went with a particular datastructure, etc. You can build up a narrative of code that will help the next programmer who comes along.