So I'm getting used to TDD, but I've come across an unexpected problem: I'm getting really tired of 100% code coverage. The tests are getting more tedious to write than the code itself, and I'm not sure if I'm doing it right. My question is: What sort of things are you supposed to test, and what sort of things are overkill?
For example, I have a test as follows, and I'm not sure if its useful at all. What am I supposed to do so that I still follow TDD but don't get tired of writing tests?
describe 'PluginClass'
describe '.init(id, type, channels, version, additionalInfo, functionSource, isStub)'
it 'should return a Plugin object with correct fields'
// Create test sets
var testSets = new TestSets()
var pluginData = {
'id' : null,
'type' : null,
'channels' : null,
'version' : null,
'additionalInfo' : null,
'functionSource' : null,
'isStub' : true
}
testSets.addSet({ 'pluginData' : pluginData })
var pluginData = {
'id' : "testPlugin1",
'type' : "scanner",
'channels' : ['channelA', 'channelB'],
'version' : "1.0",
'additionalInfo' : {'test' : "testing"},
'functionSource' : "function () {alert('hi')}",
'isStub' : false
}
testSets.addSet({ 'pluginData' : pluginData })
for (var t = 0; t < testSets.getSets().length; t ++) {
var aTestSet = testSets.getSet(t)
var plugin = new Plugin().init( aTestSet.pluginData.id,
aTestSet.pluginData.type,
aTestSet.pluginData.channels,
aTestSet.pluginData.version,
aTestSet.pluginData.additionalInfo,
aTestSet.pluginData.functionSource,
aTestSet.pluginData.isStub )
plugin.getID().should.eql aTestSet.pluginData.id
plugin.getType().should.eql aTestSet.pluginData.type
plugin.getChannels().should.eql aTestSet.pluginData.channels
plugin.getVersion().should.eql aTestSet.pluginData.version
plugin.getAdditionalInfo().should.eql aTestSet.pluginData.additionalInfo
eval("fn = " + aTestSet.pluginData.functionSource)
JSON.stringify(plugin.getFunction()).should.eql JSON.stringify(fn)
plugin.getIsStub().should.eql aTestSet.pluginData.isStub
}
end
end
end