TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Should you TDD a MVP?

57 pointsby famover 12 years ago
Is it beneficial to do so or does it simply add too much overhead?

22 comments

DanielBMarkhamover 12 years ago
The question here is really "what's the test?" You have to reailze <i>the MVP _is_ the test</i>.<p>For a startup, customers are how you pass the test. Anything else is a red light. So in the most important way possible, as long as you have no customers, you have a test which is failing.<p>This is important because the maintainability you're looking for in a startup is your relationship with the customer. Manage that and the rest takes care of itself. If you are already in a business, yes, "maintainability" means writing code that will last. But if you've just got an idea or a dream, you've got nothing worth maintaining. Nor will you ever.<p>Put differently, your technical debt can never exceed the economic value of your code, which in a startup is extremely likely to be zero. (Different scenario entirely for project-based work for ongoing businesses, which is why TDD makes so much sense in that scenario)
评论 #4987268 未加载
评论 #4987388 未加载
pbiggarover 12 years ago
I'm the founder of <a href="https://circleci.com" rel="nofollow">https://circleci.com</a>, so I feel I have a little perspective here from talked to dozens of startups about this very question.<p>You should test a different amount based on your goals. TDD does not deliver value to your customer directly, so the only way its even usable in an MVP is helping you iterate and deliver the MVP faster.<p>A common mistake, and it feels like you're doing it here, is to think that TDD is a best practice that you have to do, rather than thinking about how to apply it to improve your productivity.<p>So how will testing help in an MVP? It allows you verify that you haven't broken anything when you write new code, and when you rewrite existing code. But because you'll constantly throw out code, spending a long time doing this will literally be wasted as you throw out the code you're testing.<p>Avoid writing the sort of massive extensive tests that many associate with TDD. When you unit test a function, test or two cases at most, any more that that is overkill. If it takes you 2 minutes to write a function, a function + tests should take at most an extra 30 seconds. If you can't think how to test it, don't.<p>So some specific advice:<p>- when you write a function, you're likely to test it somehow manually (refreshing the browser, at the REPL, etc). Take that manual test and put it into the test framework. It should take 10 seconds more. If it is more effort than this, don't bother.<p>- write MVP-type tests: "what's the minimum I can write here to viably test this"? 1-2 test cases, at most. A positive test and a negative test ideally. And then you're done, move on.<p>- avoid full-browser tests. Those things are a massive time sink, and nothing will change more than your front-end.<p>- use a CI service (self-plug: <a href="https://circleci.com" rel="nofollow">https://circleci.com</a>). This means you don't have to run tests before you push. Just push and let the server catch it.
biesneckerover 12 years ago
No, if your MVP is a total throwaway that you're using solely to validate a hypothesis, and once/if it's validated you'll be redoing everything.<p>Yes otherwise.<p>My experience with TDD is that the cost/benefit curve doesn't really pay off until you need to refactor or significantly expand a project, at which point having good test coverage saves you an enormous amount of time/pain.
评论 #4986834 未加载
sprobertsonover 12 years ago
If TDD isn't something you normally do, it'll likely be too much overhead. If you're a TDD expert and that's what you always do, go ahead.<p>The purpose of an MVP is to ship something that works as quickly as possible, so it's not the ideal time to be trying out a new technique.
j45over 12 years ago
What I'm writing below is meant in general, and not at the OP.<p>The purpose of an MVP is to find the minimum amount of value that a customer can't live without. An MVP is finding the 5 things you should have done in hindsight out of the 30 on your mind.<p>It sounds like you're focussing on yourself, and making your own life easier with TDD and not the customer. Wrong priority. You shouldn't expect your MVP to be here in 10 months.<p>Quit trying to prematurely optimize an empire that doesn't exist yet. Even if you write everything perfectly, you'll rewrite it from coding yourself into a corner and having to work out of it. You don't know what the problem-solution fit is, let alone whether theres a market of people willing to pay for it.<p>As history has shown, customers don't care what you code in, or how you code. It's more about building software that solves a pain and a problem, first, if you're serious about using the term "MVP". Sometimes folks keep doing what they've been doing and sprinkle some lean terms on it to make it sound like they're different.<p>TDD helps where there is complex business logic, not getting and setting basic information, which most MVP's do. If you have something that complex, it might not be an MVP.<p>Focus on the MVP, finding a product-market fit, and a problem-solution fit. Get out of the building and quit using methodologies as an excuse to analysis paralysis yourself.
schmrzover 12 years ago
I think that this is a wrong question to ask. You have probably so many more important questions to answer while working on your MVP.<p>If you are accustomed to test driven development then you will know (or at least you will be able to reason about it) when to apply it and when not to. It is just another development practice. But I do not think that you will fail if you do TDD or if you do not. But you do risk failing if you emphasize the wrong things such us should we use X or Y development practice. Use whatever works for you and your team (if you are not alone).<p>To give you a more concrete answer: follow common sense and your team's suggestions. Avoid making a development practice one of your priorities.
LnxPrgr3over 12 years ago
Personally I wouldn't, but my opinion doesn't matter.<p>Does TDD help you? If so, use it! If not, don't! The whole point of an MVP is to ship something ASAP. Do whatever helps you do that.<p>Personally I've found TDD to be a tremendous waste of time for most things, but I know some people swear by it. It's your product. Git 'er done in whatever way you've learned to get things done.<p>Edited to add: People talk a lot about TDD leading to more maintainable, less coupled code. There's more than one way to skin a cat—not using TDD doesn't necessarily doom your codebase, and using TDD won't necessarily save it. Like I said, do whatever works for you.
paulbjensenover 12 years ago
I think it's ok to go without tests at the start of your project, but at some point you have to transition to using TDD, otherwise the ability to refactor the codebase or change existing features becomes difficult and time-consuming.<p>To give a rough idea, I spent ~ 2 1/2 months working on my app (Dashku.com) before I wrote a single test for it. Then when a company approached and asked to use it with a special requirement, I realised it needed tests in order to be deemed production-worthy. Now the app has tests (both unit and integration), and I'm now resuming adding features to the product.
frioover 12 years ago
It really depends on the degree to which you do it. I'd argue that just having one or two very basic acceptance tests is probably all you want when you're testing the waters with an MVP. The most all-encompassing test you can make; and make it from a client-side perspective (so: JS or Python or something exercising your HTTP API).<p>For instance, if you were making a library app: test that a logged in user can add a book to it. That's as simple as:<p><pre><code> class AcceptanceTest(TestCase): def testThatAUserCanAddABook(self): r = requests.post("/books/", data={"title": "My New Book"}, auth=HTTPBasicAuth('user', 'pass')) self.assertEquals(r.ok, True) </code></pre> Then, do the absolute bare, hacky minimum to get that test passing: implement a server which simply returns 200 to that URL.<p>As you're working, I've found that having that singular, overarching acceptance test will speed you up massively; there's no need to arduously step through your UI, or run through various httpie commands; the test covers you as you refactor to implement your user authentication, basic API, and backing database.<p>So, yes: TDD can be a big time investment, and can slow down your launch if you fully break your work down into unit tests. But having simple, straightforward, all-encompassing acceptance tests can give you a great base for getting work done.<p>(Note that after launch, once you start writing more tests, you should eventually throw away that acceptance test, as more componentised and faster unit tests replace it :)).
christophersleeover 12 years ago
The key question here is, are you building a quick and dirty prototype, or are you building an MVP? MVP doesn't mean a garbage prototype. Depending on what you're doing, an MVP could still take significant time to build (and your MVP would take 1 month vs 3 months for the "full product.")<p>IMHO, if you're worried about supporting and maintaining your app, and concerned about your users not having a buggy experience, you should TDD it.
davidwover 12 years ago
You should at least put a testing framework in place, and test some low-hanging fruit. That'll make it easier to get momentum going for more testing if things continue, and at least give you some minimal coverage.
评论 #4987105 未加载
peterhuntover 12 years ago
TDD is good for some things, terrible for others.<p>TDD's great when what you're working on is easy to test, like your data backend for your application.<p>It'll vary based on your product of course, but in my experience I've found the frontend to be the big time sink in development. Using TDD for contemporary frontend development is, in my opinion, a big time sink since the cost/benefit ratio of frontend testing today is way too high.<p>tl;dr use TDD for your backend (data model invariants) and hack your frontend as quickly as you can (on top of a decent frontend stack so you don't get <i>that</i> messy).
jdlshoreover 12 years ago
This is a really good and interesting question, and it's one I've been struggling with myself.<p>The problem boils down to this: TDD makes your software more maintainable (if you do it well) and it lowers your cost of development. <i>However,</i> it also takes significant time and effort to figure out how to test-drive a technology for the first time. Everybody can TDD a Stack class; TDD'ing a database, or a web server, or JavaScript [0] is a <i>lot</i> harder.<p>So the answer seems simple: use TDD for the parts you already know how to TDD.<p>But it's <i>not</i> so simple! It's much harder to add tests to existing code than it is to TDD it from scratch. Sometimes, it's flat-out impossible. The expense is so high, there's a very good chance that you'll <i>never</i> get around to adding tests to the un-TDD'd code. It will hang around causing bugs, preventing refactoring, and sapping your agility forever, or until you rewrite... and a rewrite of any significance will halt your company in its tracks, so you won't do that.<p>So the reality is that, anything you don't TDD from the beginning, you'll probably never be able to TDD. Companies that go down this road find themselves doing a major rewrite several years down the road, and that's crippling [1].<p>There's another wrinkle on top of this: manually testing code and fixing bugs is <i>expensive</i>. Once your codebase gets above a certain size--about six developer-weeks of effort, let's say--the cost to manually test everything exceeds the cost to TDD it. (The six weeks number is a guess. Some people argue it's less than that.)<p>So the real answer is a bit more nuanced:<p>1. <i>If</i> your MVP is truly a throw-away product that will take less than six weeks to build and deploy and you'll <i>never</i> build on it after that, use TDD only where it makes you immediately faster.<p>2. If your MVP is the basis of a long-lived product, use TDD for the parts you know how to TDD and <i>don't do</i> the parts you don't know how to TDD. Be creative about cutting scope. If you must do something you don't know how to TDD, figure it out and TDD it.<p>3. It's okay to be a bit sloppy about TDD'ing the edges of your app that are easily rewritten or isolated in modules. But be very careful about the core of your system.<p>That's my opinion based on 13 years of doing this stuff, including building five successively-less-minimal MVPs over the last nine months for my JS screencast. The first three MVPs were zero coding, the fourth was a throw-away site, and the fifth was TDD'd with aggressive scope cutting to minimize the number of technologies that had to be TDD'd.<p>[0] Shameless plug: I have a screencast on TDD'ing JavaScript that I'll be opening up to the public, on a subscription basis, in a month or so. <a href="http://www.letscodejavascript.com" rel="nofollow">http://www.letscodejavascript.com</a> .<p>[1] Rewrites are crippling: See Joel Spolsky's "Things You Should Never Do, Part I." <a href="http://www.joelonsoftware.com/articles/fog0000000069.html" rel="nofollow">http://www.joelonsoftware.com/articles/fog0000000069.html</a> (There is no Part II, by the way.)
评论 #4987163 未加载
评论 #4986948 未加载
评论 #4987195 未加载
PaulKeebleover 12 years ago
Those that TDD a lot have come to realise what TDD does is help you find a good design. It teaches you something about the way in which you code and design and allows you to cheaply play with the alternatives. It also ensures the code works and ensures so in the future as you undergo changes.<p>BDD for functional testing ensures that the functionality you test works and again that before you cut code you have thought about how your functionality is going to work. These are valuable exercises to do with or without the code to run.<p>So when it comes to an MVP to test the idea how well does it have to work and how well does it have to be designed? Some amount of your system will be critical and if in the process of changing it you break that functionality you may have no product. A certain amount of confidence in the core of what you are building is important, having it automated will allow you to change quickly. Ensuring 100% code coverage is not important, some bugs when you are small are probably acceptable.
gkarthikover 12 years ago
It depends. A MVP is basically used to test if your core functionality is popular among users and also to collect some useful feedback from users via a simple system.<p>I personally never developed a MVP for my first start up, Tune Patrol.<p>While, while making Tune Patrol, a social music discovery platform, my MVP would've involved just putting up a few songs and letting users play them. Like I said, this would've helped in two ways,<p>1. Get traction. Users know that you're up and running.<p>2. It helps test to see what kind of features a user might want by using a good feedback system.<p>Instead I went on to develop a product with a lot of functionality. My first problem was that I couldn't immediately determine if users liked my understood the functionality completely. Luckily for me turned out users understood pretty much everything and now we are developing on it.<p>You could also read "Lean Startup" by Eric Ries where he stresses upon the importance of a MVP and quotes a few examples from his own experiences.
programminggeekover 12 years ago
I would TDD in either case simply because if you end up maintaining it at all, you're going to wish you had tests. Also, I wrote an architecture that makes starting from day one using TDD much easier. It's called Obvious: <a href="http://obvious.retromocha.com" rel="nofollow">http://obvious.retromocha.com</a><p>Once you understand the concepts, you can whip up a simple crud app in a couple hours. Example app here: <a href="https://github.com/RetroMocha/obvious_status" rel="nofollow">https://github.com/RetroMocha/obvious_status</a>
ollysbover 12 years ago
When I'm starting out I find writing a cucumber scenario is a great way to focus on getting a useful feature done. It's the first thing I add to a project. The general setup is done as part of getting that first scenario to pass. After that I do whatever is fastest. I use cucumber scenarios as tracer bullets for new areas of functionality but if I'm refining perhaps I won't bother. As always though, it depends...
vlokshinover 12 years ago
front end, no. It changes too much. Back end, maybe. Only for the core logic that (probably) won't change.<p>Basic rule: don't let work create more work if the benefit's not worth it. You probably knew that already, so just stick to it.
mitchiover 12 years ago
I initially thought the question was "Do we ask our MVP to use TDD ?" -.-
jmountover 12 years ago
"In fact I usually like to TYZCMZQ when I'm not VJBDTLJX-ing!"
评论 #4986782 未加载
volandovengoover 12 years ago
short answer: no.<p>The purpose of a MVP is to prove the idea using the minimal amount of effort. TDD takes about 50% more time.
martincedover 12 years ago
Seen that TDD refer to "Test Driven Development" I was nearly sure that the question asked about "MVP" / Model View Presentation.<p>I've implemented lots of different of UIs using MVC type 1 and 2, HMVC / PAC etc. and, as a developer, I don't have single clue as to what "MVP" means here. Maybe some context to remove the ambiguity would be good in laconic questions like this one, especially seen that the other acronym is used.<p>Google for "TDD test driven development MVC" and you'll see that I'm 100% correct on this one ; )
评论 #4987093 未加载
评论 #4987101 未加载