Tag Info

Hot answers tagged

76

Regression testing It's all about regression testing. Imagine the next developer looking at your method and noticing that you are using magical numbers. He was told that magical numbers are evil, so he creates two constants, one for the number two, the other one for the number three—there is nothing wrong in doing this change; it's not like he was ...


43

Because nothing is so simple that there can't be bugs. Your code, while on the face of it looks to be bug free. It is in fact a simple programmatic representation of a polynomial function. Except it has a bug... public function polynominal($a, $b, $c, $d) { return $a * pow($x, 3) + $b * pow($x, 2) + $c * $x + $d; } $x is not defined as an input to ...


20

Yes. If we could say with 100% confidence, with certainty: this function will never be edited and will never run in a context which could cause it to fail - if we could say that, we could drop the tests and save a few milliseconds on every CI build. But we can't. Or, we can't with many functions. And it's simpler to have a rule of running all the tests ...


12

Everything said in the other answers is correct, but I will add one more. Documentation Unit tests, if well written, can explain to a developer exactly what a function does, what its input/output expectations are, and more importantly, what behavior can be expected of it. It can make spotting a bug easier and lower confusion. Not everybody remembers ...


7

Is there a technique for unit testing both components in one run? That would actually be the opposite of unit testing - unit testing, especially in TDD style, means to test your components in isolation. Thus the answer is yes, "run separate test suites for the JS and PHP sections", otherwise it is not unit testing and not TDD. Of course, automated ...


7

Generally, one would better be judicious about using protected access at all. The reasons for that are laid out in answers to prior questions over here: Why is Clean Code suggesting avoiding protected variables? As for using it the way you think of here - weakening access limitation because it feels like more comfortable to test - it looks like a terribly ...


3

Don't write GUI tests to match the GUI. Write acceptance tests that match requirements You could write your tests like this: Given I enter "user" into the username field and "pass" into the password field And I click the "Login" button When I click the Find User button And I enter "foo" into the username field And I click "Search" Then I should see a ...


2

For a good definition of Test Driven Development, I suggest you read Doc Brown's post. Here is how I would answer a similar question: All three practices are not mutually exclusive and can be combined into the larger software development process. Developing based on User Stories in iterative development cycles (Agile) does not exclude the engineering ...


2

The important thing is to distinguish between TDD and ATDD. The AT there stands for "acceptance tests", and this refers to development where you first start with an acceptance test, which is likely to test the entire stack. This is also sometimes called "outside-in test driven development". When people talk about TDD, the "T" there probably refers ...


2

Reality Check I have been in challenging environments where testing is "a waste of time" during budgeting and schedule, and then "a fundamental part of quality assurance" once the customer is dealing with bugs, so my opinion is more fluid than others might be. You have a budget. Your job is to get the best product you can on that budget, for whatever ...


2

You don't need a setting that says if you are in development or production or not. You just need settings that tell your application how to handle certain things. API keys, database connection strings,... these are all basic 'read this value and use it' things and this is the kind of stuff that configuration files are good at. It's a little different if ...


1

A very clean way is using Git: Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. For more information and downloads: https://git-scm.com With Git you use branches, such as develop, master, feature/, etc. Read more here: ...



Only top voted, non community-wiki answers of a minimum length are eligible