tdd

Mocha and Chai test fails when testing function with setInterval

試著忘記壹切 提交于 2019-12-06 07:30:17
问题 I'm new to TDD and working with Mocha and Chai. I have created a test that passes when a value is increased, but when that increase is put within a setInterval, it fails. The objective of this code is to have something move across the screen. function startMovingThing(){ var position = setInterval(function() { moveThing(10); }, 100); } function moveThing(number){ thing.position += number; thingOnScreen.style.left = thing.position + 'px'; } test: describe('Thing', function() { it('should

Developing N-Tier App. In what direction?

感情迁移 提交于 2019-12-06 06:36:37
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 ?) 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 working from the Presenter. This provides you with a very light-weight object (since the presenter is basically

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

自作多情 提交于 2019-12-06 05:48:19
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. Check out NCrunch . NCrunch constantly checks the code as you are typing, and lets you know whether each line of code is covered by at least

Is there a preferred BDD style unit-testing framework for Python?

房东的猫 提交于 2019-12-06 04:29:25
问题 I was wondering if there are any BDD-style 'describe-it' unit-testing frameworks for Python that are maintained and production ready. I have found describe, but it doesn't seem to be maintained and has no documentation. I've also found sure which reached 1.0, but it seems to just add syntactic sugar instead of writing assertions. What I'm really looking for is something similar to RSpec and Jasmine that enables me to setup test suites. The describe-it syntax that allows for testing multiple

When doing BDD, must I first TDD each piece of code needed to make an acceptance test pass?

泄露秘密 提交于 2019-12-06 02:15:04
问题 I've been given a kata to work on over the weekend. Before starting it I really just wanted to gather some thoughts. I'm not looking for the solution, just some ideas on the best approach/practice. From the conversation I had it would seem that I need to use a BDD --> ATDD (relate to scenarios in gherkin) --> TDD approach. I'm just looking to work out the best approach. My current thinking is to 1) Create a specflow project and distill the user story into a gherkin. 2) Create the associated

How can I reference external data providers in phpunit?

烂漫一生 提交于 2019-12-06 01:53:25
I am trying to run some tests using a common data provider in PHPUnit. See below test: namespace AppBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use AppBundle\Tests\DataProvider\XmlDataProvider; class DefaultControllerTest extends WebTestCase { /** * @dataProvider XmlDataProvider::xmlProvider * @covers ReceiveController::receiveAction() * @param string */ public function testReceive($xml) { $client = static::createClient([], ['HTTP_HOST' => 'mt.host']); $client->request( 'POST', '/receive', [], [], [], $xml ); $response = $client->getResponse(); $this-

Visual studio parameterized unit test like java

烈酒焚心 提交于 2019-12-06 01:48:30
问题 In a Java test environment I can use parameterized unit tests as in the following code: @RunWith(value = Parameterized.class) public class JunitTest6 { private int number; public JunitTest6(int number) { this.number = number; } @Parameters public static Collection<Object[]> data() { Object[][] data = new Object[][] { { 1 }, { 2 }, { 3 }, { 4 } }; return Arrays.asList(data); } @Test public void pushTest() { System.out.println("Parameterized Number is : " + number); } } How can I do this in a

What is your favorite/recommended project structure and file structure for Unit Testing using Boost?

蓝咒 提交于 2019-12-06 01:07:29
问题 I have not used Unit Testing so far, and I intend to adopt this procedure. I was impressed by TDD and certainly want to give it a try - I'm almost sure it's the way to go. Boost looks like a good choice, mainly because it's being maintained. With that said, how should I go about implementing a working and elegant file-structure and project-structure ? I am using VS 2005 in Win XP. I have been googling about this and was more confused than enlightened. 回答1: Our Boost based Testing structure

Is better to detect for exceptions and throw them or just let runtime throw them?

前提是你 提交于 2019-12-06 00:19:58
Lets say there is setup like this: public class MyClass { public void DoSomething(string Data) { //if (String.IsNullOrWhiteSpace(Data)) //throw new NullReferenceException(); //Do something with Data and let it throw?? } } public class EntryPointClass { public void DoIt(string Data) { var logicClass = new MyClass(); try { logicClass.DoSomething(Data); } catch(Exception ex) { } } } In DoSomething I can detect a problem and throw an exception. In testing EntryPointClass I can test the expected outcome or test that something in happened in the catch. Why is it better to throw an exception rather

What are the good practice to test/inject private field in C#

耗尽温柔 提交于 2019-12-06 00:07:33
My apologies if this a duplicate. I have been given the task to add some coverage for the method and been told to mock the private List<string> property. My question is: Is there a way to test private fields? The solution I found is adding new constructor just to inject this private list. I am not sure whether this is the right way, so any help will be highly appreciated. public class Class1 { public Class1(List<string> list)//This is just for Unit Testing { list1 = list; } private readonly InjectRepository _repository; // public Class1(InjectRepository repository)//This is the actual