Saturday, 15 March 2014

c# - Should I write tests before they will compile? -



c# - Should I write tests before they will compile? -

i've been trying follow loose tdd workflow 1 of open source projects. it's api other programmers use.

as such, 1 key aspect making api "work" designing how consumed. i've heard people writing tests before they'll compile waste of time , prone constant rewrite until api stable. i've heard should follow workflow so:

write tests won't compile make compile make green

i've been trying follow workflow, end weird things. instance, in api have these 2 methods:

handles(string pattern); //had 1 handles(ipatternmatcher pattern); //needed 1

i needed sec form of method added api. so, ended dead simple test so:

public void handles_supportsipatternmatcher() { var api=new myapi(); api.handles(new testpatternmatcher()); }

which seems waste after gets implemented.

should go on next workflow, or there ways improve it? how maintain writing tests check compiler errors? since it's publicly consumable api, should worry tests this?

no.

do not write code tests whether compiler working. kind of tests create lot of sense if using dynamic languages (or dynamic features in static language), tell you forgot something, or refactored failing unit test.

the point of unit test execution fail build if in error. if have compiler error in code, build fail. there no need second-guess it.

c# unit-testing tdd nunit api-design

No comments:

Post a Comment