Tag Info

Hot answers tagged

16

Developers are very, very good at abstraction. If you give us half a problem, we'll come up with the whole solution. In fact, we're so good at this, we won't even notice that we've only got half the problem. We're "solution space" people. Our job is to solve problems. Testers, on the other hand, are "problem space" people. They're the ones who ask, "What ...


8

Your first violation ("The code that is written for interface is not driven by test.") is not valid. Let's use a trivial example. Suppose you're writing a calculator class, and you're writing an addition operation. What test might you write? public class CalculatorTest { @Test public void testAddTwoIntegers() { Calculator calc = new ...


7

How are this kind of things usually dealt with? By not unit testing the files. Generally, there's some intermediary format that defines the content of the file. You would test that the intermediary content you expect is being sent off to be PDF-ified. Basically, isolate everything but actually encoding your output to PDF. In an ideal world, that work ...


6

It's not generally needed. As @Telastyn says, if the test case fails, then it will become quickly and readily apparent what method failed. The real need is to have the purpose of your test easily understood by those that are adding, reviewing, or modifying tests after you (even if that person is also you), and are reviewing the code and searching for ...


6

The "ubiquitous language" should be semi-formal because you want to have conversations about how the code should behave. If you make the language formal, you'll end up having more conversations about adhering to the formal language than you will about the behaviour of the code. I wrote a blog post that illustrates what happens when the concept of formal ...


4

I've done this by using a library to parse the files. Sounds like you already have one available so you should use this. Even if you could compare the entirety of the binary files, I wouldn't recommend this. Lets say you've got 100 tests that are testing various things by comparing the entire binary output. Then a new requirement comes in that the title ...


2

File output usually belongs to integration-tests(=having some components working together) and not to unittests(=test one component in isolation) if your pdf-generation is implemented in a way that the same input always produces the same output you can try approvaltests which does a binary compare to the previous call result. if there is no previous result ...


2

In TDD should I have to write Test first or Interface first? It all depends on how orthodox / religious you want to do TDD. I am learning TDD Since you are learning, you should experiment to get a personal workflow, which works for you. If you want to do it according to the books, you write at first a test, which obviously will fail, because ...


2

No, you do not need to add messages to most assertions. Writing unit tests as you suggest would be needlessly tedious. Presumably the Assert.IsTrue method will throw an exception saying something like "Expected true, got false". The ensuing stack trace will pinpoint the cause of the failure. N.B. In general, as a programmer, you should not be spending ...


2

One situation in which test-first really gets in my way is when I want to quickly try out some idea and see if it can work before I write a proper implementation. My approach is normally: Implement something that runs (proof of concept). If it works, consolidate by adding tests, improving design, refactoring. Sometimes I do not get to step 2. In this ...


1

Acceptance tests should be written first, before the code is written. When they pass, you know the feature is complete and does what it is supposed to do. However, most of these tests only follow the happy path. Let's consider two scenarios: Your QA department is able to handle writing their own automated tests. In this case, you've saved them the ...


1

This is fully up to the company or organization you are working in, so ask the persons who are responsible for defining the organizational structures. However, there are some rules of thumb which distribution of tasks will work better. For example, if your QA department consists of people with no programming knowledge, it won't make sense to give them the ...


1

Testing code is still code, intended to accomplish some function. That it's a "back room" or "back stage" function is just a detail. Now, you have a codebase with 200 functions, that minimally accomplishes the coverage you need, and only 10% works. If this were a user-facing codebase, you'd probably conclude it wasn't worth updating as-is, where-is. That a ...


1

Testing output files is always a difficult thing, same goes for testing downloading files from the web or output to the console. One question you should ask yourself is: "How far can I test until I need the file?" Most of the logic can be tested by using some kind of replacement code, or simple text file generator. Looking at your question you can generate ...


1

There are a few different ways of testing files: Binary comparison. Output a "golden" result file for each test; manually confirm it's right; store it and compare it against future file outputs. Pros: Simple. Cons: Fragile. Prone to false negatives (esp if files contain metadata, like 'creation date' that change even when the 'payload' data does not.) ...


1

go ahead an formalize the ubiquitous language if it helps describe/define/solve the problem in the chosen domain - that's called a Domain Specific Language But don't expect business users to write DSL; it's enough if they can read it, to facilitate the conversation described by Lunivore


1

This kind of testing is why mocks were invented. The main idea: You write a mock for your object (map, behavior, character, ...), then write tests using that mock instead of the actual object. People sometimes call mocks stubs, and I believe there are other words for both. In your case, you would write a mock for the map whenever you need to test the ...



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