tdd

PHPUnit, Interfaces and Namespaces (Symfony2)

痴心易碎 提交于 2019-12-10 13:32:07
问题 I'm currently working on an open source bundle for Symfony2, and really want it to be the dogs nadgers in terms of unit test coverage and general reliability, however I've run into a snag due to my lack of PHPUnit knowledge (or a complex scenario, who knows).. At present, I have a Mailer class, for handling individual mail scenarios. It looks a bit like this: <?php use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Component\Routing\RouterInterface; class Mailer {

Why should I avoid using DbUnit to test MySQL?

空扰寡人 提交于 2019-12-10 13:17:59
问题 I have recently become involved with some TDD using PHPUnit. I have to test a database-driven app, and read about the DbUnit extension, which I was planning to research and implement over the coming weeks. However, I have come across this presentation by the man himself - Sebastian Bergmann - He has a slide entitled 'Avoid testing against MySQL if you can', which has cast some doubts upon my escapade. Can someone explain the reasons why I should not test against MySQL? Thanks 回答1: Two reasons

How to share resources between unit test and instrumentation test in android?

非 Y 不嫁゛ 提交于 2019-12-10 12:39:34
问题 I'm following this post, http://blog.danlew.net/2015/11/02/sharing-code-between-unit-tests-and-instrumentation-tests-on-android/, to share code, but how to share an asset?, like a fixture file?, I want to mock an api response, so I have a JSON file to do it, but I try this: https://gist.github.com/nebiros/91a68aaf6995fa635507 In Unit Test, this works: ClassLoader.getSystemResourceAsStream("some_response.json"); but in Android Intrumentation Tests, it doesn't, where can I put those fixture

Go: Test cannot pass?

风格不统一 提交于 2019-12-10 12:33:28
问题 I'm having a problem making this test pass. The problem is, the Write() method in my struct needs to write to a property, but io.Writer interface does not accept pointer as its receiver. filelogger.go: package logger import ( "io" ) type FileLogger struct{ File io.Writer } func NewFileLogger(file io.Writer) *FileLogger{ return &FileLogger{file} } func (this *FileLogger) Log(message string) error { _, err := this.File.Write([]byte(appendNewLine(message))) return err } filelogger_test.go:

Count number of files in a Zip File with c#

纵然是瞬间 提交于 2019-12-10 12:20:53
问题 I'm generating some .csv files and I need to compress this inside a Zip File. Ok, I have a framework to do this and probably everything will be fine. But! As TDD says I just can write code, after I have some tests! My first test sound simple, but I'm having some problems reading the Zip file, anyone know a simple way to count the number of files in my zip file? 回答1: You seem to be looking for something like DotNetZip. EDIT : For example: int count; using (ZipFile zip = ZipFile.Read(path))

Developing N-Tier App. In what direction?

旧城冷巷雨未停 提交于 2019-12-10 11:09:24
问题 Assuming the you are implementing a user story that requires changes in all layers from UI (or service facade) to DB. In what direction do you move? From UI to Business Layer to Repository to DB? From DB to Repository to Business Layer to UI? It depends. (On what ?) 回答1: The best answer I've seen to this sort of question was supplied by the Atomic Object guys and their Presenter First pattern. Basically it is an implementation of the MVP pattern, in which (as the name suggests) you start

In TDD, splitting main class into sub classes during refactoring

巧了我就是萌 提交于 2019-12-10 10:58:05
问题 I am trying to follow TDD and am kind of new to it. I have a interface (Java) to be implemented. So I started writing test cases for the interface behaviour, making them fail and fixing them by adding or modifying code. However, as I see the main class is growing in size, I am breaking the main class into separate classes. But for some of the sub-classes, I realize that it's better to test them separately and mock them in the main class test cases. But when I did that, I had to rewrite the

How can I automaticly compile only projects that have changed when I build my solution in VS2010?

£可爱£侵袭症+ 提交于 2019-12-10 10:33:29
问题 I am doing TDD development on a large solution in my company, we use visual studio 2010, I have the problem of long compile time, because it compiles the whole solution each time I do a small change in only one file, It compile very often so slows me down. Is there a way to tell VS2010 to compile only the project that has changed or some other solution to my problem, we have 20 projects inside the solution, I often touch 2-3 of them when I code. Thanks. 回答1: Check out NCrunch. NCrunch

Extracting class when TDD'ing. How to test the new extracted class?

随声附和 提交于 2019-12-10 09:36:18
问题 So I had a couple of methods in my main class that used a matrix to set pixels on or off. I got all my current tests running and so, and I've decided it's already time to pull out some of that logic related to the matrix and such and create a Matrix class. My question is, besides the tests I currently have for my SUT class (I'm just in the beginning, so I currently only have one class, the SUT's main one), should I create Unit-Tests for it? If so, how do you do it? I mean, do I let all my

PHPSpec Catching TypeError in PHP7

会有一股神秘感。 提交于 2019-12-10 03:21:24
问题 I want test an example method with scalar type hinting and strict types in PHP7. When I don't pass an argument, the method should throw a TypeError . PHPSpec return fatal error: Uncaught TypeError: Argument 1 passed to Example::test <?php class Example { public function test(string $name) { $this->name = $name; } } class ExampleSpec extends ObjectBehavior { function it_is_initializable() { $this->shouldHaveType('Test\Example'); } function it_check_test_method_when_not_pass_argument() { $this-