New answers tagged

0

Generate a reference file. Simply shove the result of mp.write on mock values inside the repository in a file then you'll very easily test the encode and decode functions work by testing their result on the same mock values against the file. Your option 2, basically. Advantages over using mp.write on the fly are multiple, the most important being isolation. ...


0

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. -- C.A.R. Hoare One thing to consider is whether your design can be simplified to the point that other measures of evaluating its correctness ...


0

Unit testing requires you to completely isolate the behavior under test. Reading and writing to disk means you cannot write unit tests for that code. Instead, write integration tests using test fixtures. Test fixtures allow you to test code against real example files. There are a couple of comments in the code in your question that hint at ways to retractor ...


0

My thought is you should use the alternative B. As I can see if you have to change the code to run the alternative A, such behavior is not correct. Also, alternative B seems mostly like a snapshot test because it preserves a system functionality.


11

Data must always be validated again in the backend, even if it is already validated in the frontend. The fundamental principle at work here is this: you cannot trust the frontend. It could contain a bug or virus. It might not be your frontend at all; it might be some other program written by a bad actor to gain access to your systems. So why validate in ...


3

Often times for higherlevel specs I would mock out the foreign thing to test different possible cases and then have as few as possible full integration tests just to verify that everything works together. I am not familiar with Pandoc but I assume you can peg it to a version if you are using it on your project. I would run a suite of integration tests to ...


2

When you use static initialization, you give up any explicit control over the order of initialization. If things work, it's for one of the following reasons: the static initialization only involves constant expressions. you've carefully read the language specification, and have concluded that the initialization is guaranteed to work correctly. things just ...


1

Your backend should implement the illegal case C probably by reporting an error back. The shipping backend would include that code. If you write tests for the backend, they should test the “impossible” case C because any case should be handled correctly by your backend. If you mock the backend, you should make sure that the mocked backend works the same as ...


4

What behavior would you expect to see when a testcase calls registerForArea('C')? As your area-selection input control is apparently designed such that only valid areas can be selected/entered, I would find it entirely normal if the front-end code blindly passes the selected area on to the backend. The front-end must make it hard for users to enter invalid ...


Top 50 recent answers are included