﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>[ICR] commented on A bad test</title><description>Doesn't this suggest it should have been a NotImplementedException originally?</description><link>http://ayende.com/155617/a-bad-test#comment16</link><guid>http://ayende.com/155617/a-bad-test#comment16</guid><pubDate>Sun, 20 May 2012 20:28:40 GMT</pubDate></item><item><title>Chris Wright commented on A bad test</title><description>There should have been separate tests for each of those functions, positioned where you would have naturally written the tests for the real, working functionality. That way, it wouldn't have shown up at the build server; it would have shown up as soon as you considered working on the feature that wasn't supported.

Glomming everything together means you have a submarine test, which, no matter what it's testing, is bad.

Had these tests been closer to where you were expecting, you wouldn't have thought to write this post, most likely.</description><link>http://ayende.com/155617/a-bad-test#comment15</link><guid>http://ayende.com/155617/a-bad-test#comment15</guid><pubDate>Fri, 18 May 2012 23:37:56 GMT</pubDate></item><item><title>João P. Bragança commented on A bad test</title><description>Crazy Idea: What about exposing 

public static IEnumerable[Action[IDocumentStore]] OperationsNotSupported() {}

Then you could refactor without refuctoring.</description><link>http://ayende.com/155617/a-bad-test#comment14</link><guid>http://ayende.com/155617/a-bad-test#comment14</guid><pubDate>Fri, 18 May 2012 16:58:27 GMT</pubDate></item><item><title>Mike McG commented on A bad test</title><description>Tests are designed to enforce the expectations made of the code. Those expectations can be set by interfaces, but can be supplemented by traditional documentation or other out-of-code communications.

In this case, **if** such communications have established that these methods are not supported, then the tests correctly enforce that (and are "good"). By failing when one of these methods is implemented, the developer is reminded that the expectations of the code have changed, and out-of-code communication artifacts must be updated to reflect that.</description><link>http://ayende.com/155617/a-bad-test#comment13</link><guid>http://ayende.com/155617/a-bad-test#comment13</guid><pubDate>Fri, 18 May 2012 16:31:11 GMT</pubDate></item><item><title>Vadim K commented on A bad test</title><description>This is why I love using machine.specifications for my testing framework. You can define a test without implementing it. This lets you know which features still need to be implemented.</description><link>http://ayende.com/155617/a-bad-test#comment12</link><guid>http://ayende.com/155617/a-bad-test#comment12</guid><pubDate>Fri, 18 May 2012 15:20:26 GMT</pubDate></item><item><title>configurator commented on A bad test</title><description>Parts of that test are actually quite important. shardedDocumentStore.Url can't possibly return a result that makes sense - if it returned (for example) the first shard's URL that would have been a bug. Same goes for DatabaseCommands and AsyncDatabaseCommands.

I think it's even important for GetLastWrittenEtag and Defer - because as long as you've not implemented it, an incorrect result can be far, far worse than a NotSupportedException.</description><link>http://ayende.com/155617/a-bad-test#comment11</link><guid>http://ayende.com/155617/a-bad-test#comment11</guid><pubDate>Fri, 18 May 2012 15:11:14 GMT</pubDate></item><item><title>Federico Lois commented on A bad test</title><description>As mentioned before the problem aint the test itself. It may be that it is hidden in an improper location without giving a semantic clue. 

I do have a test file dedicated to "unsupported" or "defects" in third party components. When I update any of them (including RavenDB) and they are fixed I know right away and fix the workarounds in the code. 

So I dont think it is a test, I believe it is a "note" to your team or yourself in the future where you are not actively thinking about it. </description><link>http://ayende.com/155617/a-bad-test#comment10</link><guid>http://ayende.com/155617/a-bad-test#comment10</guid><pubDate>Fri, 18 May 2012 14:08:35 GMT</pubDate></item><item><title>Paul Stovell commented on A bad test</title><description>I actually wrote a test like that against RavenDB.

A few versions ago there was a bug where Uri properties would cause Raven to think the data had always changed. So you could do this from memory:

var customer = session.Load&lt;Customer&gt;();
Assert.IsTrue(session.Advanced.HasChanges(customer));

I didn't want a broken test failing my build for a week while I waited for a new RavenDB build so I wrote it as a negative test. When I upgraded RavenDB and the test failed it was a nice reminder about the issue. 

In some ways I think the negative test had /some/ value - if I ever wondered if a problem still existed I had some proof for it. But having a test 'fail' because something 'worked' did leave a strange feeling. I'm not sure what the solution for this should be. Maybe Assert.Inconclusive()? 

Paul</description><link>http://ayende.com/155617/a-bad-test#comment9</link><guid>http://ayende.com/155617/a-bad-test#comment9</guid><pubDate>Fri, 18 May 2012 13:57:08 GMT</pubDate></item><item><title>Onofrio Panzarino commented on A bad test</title><description>I think that in the real world no one would be find useful that kind of test, neither very fanatic agilists. 
Making tests to succeed for real feature is enough a hard work.</description><link>http://ayende.com/155617/a-bad-test#comment8</link><guid>http://ayende.com/155617/a-bad-test#comment8</guid><pubDate>Fri, 18 May 2012 11:40:15 GMT</pubDate></item><item><title>Sergio commented on A bad test</title><description>It's a bad test, because you make more than one assertion in it, not because the reason you mentioned.

One test - one assertion. This way you know all failed assertions. In your test, all of them may be failing, or just the first one, you won't know.</description><link>http://ayende.com/155617/a-bad-test#comment7</link><guid>http://ayende.com/155617/a-bad-test#comment7</guid><pubDate>Fri, 18 May 2012 11:28:22 GMT</pubDate></item><item><title>Daniel Marbach commented on A bad test</title><description>How about that:
You are changing the behavior of your API. If you'd follow test first approach you'd need to write a new test for your changes. Let it fail with the not supported exception, remove the assert throws from the other test and then implement the new feature. This is not a bad test. It is you not following the principles.

Daniel</description><link>http://ayende.com/155617/a-bad-test#comment6</link><guid>http://ayende.com/155617/a-bad-test#comment6</guid><pubDate>Fri, 18 May 2012 10:14:48 GMT</pubDate></item><item><title>maciejk commented on A bad test</title><description>Also, it can give great information to other programmers - they might be browsing tests to see how they're supposed to use this functionality and when they see this test they'll immediately know that it's not yet implemented.</description><link>http://ayende.com/155617/a-bad-test#comment5</link><guid>http://ayende.com/155617/a-bad-test#comment5</guid><pubDate>Fri, 18 May 2012 09:49:59 GMT</pubDate></item><item><title>Rémi BOURGAREL commented on A bad test</title><description>If you consider your doc as part of the API, then your Test is testing your doc.

</description><link>http://ayende.com/155617/a-bad-test#comment4</link><guid>http://ayende.com/155617/a-bad-test#comment4</guid><pubDate>Fri, 18 May 2012 09:31:43 GMT</pubDate></item><item><title>Dalibor Carapic commented on A bad test</title><description>I agree with Daan. If the test ensures that any client that uses your API will get a valid error when he tries something that is not supported then the test is just fine.</description><link>http://ayende.com/155617/a-bad-test#comment3</link><guid>http://ayende.com/155617/a-bad-test#comment3</guid><pubDate>Fri, 18 May 2012 09:23:59 GMT</pubDate></item><item><title>Indranil commented on A bad test</title><description>Ah but it gives 100% code coverage. :-P</description><link>http://ayende.com/155617/a-bad-test#comment2</link><guid>http://ayende.com/155617/a-bad-test#comment2</guid><pubDate>Fri, 18 May 2012 09:16:38 GMT</pubDate></item><item><title>Daan commented on A bad test</title><description>Not entirely true: 

Your requirements are changed thus, your test doesn't meets the requirements anymore. 
</description><link>http://ayende.com/155617/a-bad-test#comment1</link><guid>http://ayende.com/155617/a-bad-test#comment1</guid><pubDate>Fri, 18 May 2012 09:14:23 GMT</pubDate></item></channel></rss>