6 ms·
Google has tests that read almost exactly like your examples. Of course, the whole search engine isn't specified by tests. However, if IMDB isn't in the top 1
by nostrademons 16y ago
Google has tests that read almost exactly like your examples.
Of course, the whole search engine isn't specified by tests. However, if IMDB isn't in the top 10 results for [avatar] or barackobama.com isn't in the top 10 for [obama], something is seriously wrong and a human should look into it.
The rest of your post is pretty good. Not sure why you've been downvoted.
- kgo 16y agoBut I imagine those are more like regression tests, right? Not write the test first BDD/TDD-style, then implement the whole search engine around it, tests. That was the implied context of that statement.
- bdclimber14 16y agoThese tests would send a red flag if they failed, but they aren't good as TDD tests. First, they are tied to a current time's context. Maybe next year, IMDB is no longer a good source for movie information, and it's so bad that it's on page 2. It could happen. In theory, your test cases should be consistent. Secondly, the TDD process is always to write code to pass tests. Well it's pretty easy to write code to return IMDB, but it's really hard to write test suite, that when coded against, would produce Google. That test would look like: search_on("avatar").should_return("www.imdb.com") if is_really_good_result(imdb) Once you are Google, then you should have these tests to make sure things keep working. However, I think it is really hard (in a bad way) to do TDD on hard problems.
- tooky 16y agoYou can't test for a particular outcome given an unknown set of input data. If you have a known snapshot of data, you can set expectations for how you want your system to behave under those circumstances. If you create a world where IMDB would rank highest for your indexing algorithm for the term "avatar", then you can expect that when you run a search it will be returned as the first result.