tdd

Database integration tests

允我心安 提交于 2019-12-05 20:07:28
问题 When you are doing integration tests with either just your data access layer or the majority of the application stack. What is the best way prevent multiple tests from clashing with each other if they are run on the same database? 回答1: Transactions. What the ruby on rails unit test framework does is this: Load all fixture data. For each test: BEGIN TRANSACTION # Yield control to user code ROLLBACK TRANSACTION End for each This means that Any changes your test makes to the database won't

Eclipse plugins that supports TDD

半城伤御伤魂 提交于 2019-12-05 20:07:16
do you know about some interesting Eclipse plugins that supports Test driven development? Infinitest and JUnitMax do "Continuos Testing". All your tests are run in the background and testing errors appear as error annotations as if they are compiler errors. Interesting indeed ;). http://infinitest.github.com/ http://www.threeriversinstitute.org/junitmax/ Pulse is a visually nice plugin that lets you track your TDD flow. http://www.happyprog.com/pulse/ 来源: https://stackoverflow.com/questions/5936945/eclipse-plugins-that-supports-tdd

How to mock JQuery with Jasmine?

╄→гoц情女王★ 提交于 2019-12-05 18:16:20
How can I test that a certain JQuery selector has been executed with Jasmine? I'm trying to do the following: spyOn($.fn, 'init').andCallThrough(); // my code expect($.init).toHaveBeenCalled(); But after this call, $('div') returns Object { selector="div", context=document, NaN=div.spec, more...} , though it has to return (and $.fn.init('div') does return it): [div.jasmine_reporter, div.banner, div.logo, 4 more...] . This stuff naturally breaks the code since the JQuery object is no longer usable. Example: Say I want to test that a JQuery selector has been called, I write: it('tests', function

Two dimensional object array return type - NSubstitute

北慕城南 提交于 2019-12-05 18:03:41
I get a cast exception System.InvalidCastException : Unable to cast object of type 'System.Object[]' to type 'System.Object[,]'. at Castle.Proxies.ITestProxy.Get2DArray() at Scratch.TestFixture.Get2DArray() in TestTest.cs: line 17 from from the below: [TestFixture] public class TestFixture { [Test] public void Get2DArray() { Substitute.For<ITest>().Get2DArray().Returns(new object[1,1]); } } public interface ITest { object[,] Get2DArray(); } can anyone throw any light on this? I'm thinking it's a NSubstitute bug? NSubstitute depends on Castle, which depends on Reflection.Emit, so they blame

Should TDD and BDD be used in conjunction?

感情迁移 提交于 2019-12-05 17:35:30
I am coming from a TDD mindset into BDD. I understand that using BDD is to focus on ensuring the behaviours and business goals of software are being met. What confuses me is that if I start using BDD in place of TDD, it seems I'm not able to test at such a low-level. For example, when writing a test with a TDD mindset, I might test that properties have been attached to the scope: it('should attach properties to scope', function () { expect(MainCtrl.items.length).toEqual(1); }); In doing this, another developer knows the assignment to scope was expected and required for future use, saving them

Is Test Driven Development good for a starter? [closed]

早过忘川 提交于 2019-12-05 17:35:05
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Expanding this question on how I learnt to pass from problem description to code Two people mentioned TDD. Would it be good for a

Should I change the naming convention for my unit tests?

こ雲淡風輕ζ 提交于 2019-12-05 15:28:59
问题 I currently use a simple convention for my unit tests. If I have a class named "EmployeeReader", I create a test class named "EmployeeReader.Tests. I then create all the tests for the class in the test class with names such as: Reading_Valid_Employee_Data_Correctly_Generates_Employee_Object Reading_Missing_Employee_Data_Throws_Invalid_Employee_ID_Exception and so on. I have recently been reading about a different type of naming convention used in BDD. I like the readability of this naming, to

Is it possible to enter debug mode for android when running junit test?

≡放荡痞女 提交于 2019-12-05 15:28:40
问题 Usually i run a junit test using adb shell am instrument -w com.android.contacts.tests/android.test.InstrumentationTestRunner . And it actually works, it will run all my tests. But when i make a breakpoints and wish to enter debug mode when running junit, it failed. The way i make breakpoints works when i debug normal android app. So i searched web, and try something like adb shell am instrument -e debug true -e class com.android.contacts.AndroidUtilsTest -w com.android.contacts.tests/android

Why do Unit Test systems include useless assertive methods? [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-05 13:15:41
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 5 years ago . I'm wondering why unittest systems like PHPUnit include what seems to be repetitive operators that just add overhead to the unit tests. I can understand a couple of those methods, but most seem like a total waste of time. public function testPop(array stack) { this->assertEquals('foo', array_pop(stack)); this->assertEmpty(stack); } vs raw code (which is shorter and faster)

What are some good examples of open source projects developed in a test-driven fashion?

南笙酒味 提交于 2019-12-05 12:40:30
I found Open source projects with good quality tests but I wanted to ask something a bit different. I'm having a hard time visualizing how to build production code using TDD practices, particularly for networked database-driven applications where big chunks of functionality are dependent on one or more external systems. The two main strategies I've seen discussed for accomplishing that are decoupling code from the systems in question and using mocks. However, my intuition is that doing either one properly would also be complex and error-prone. I'd like to take a look at some real-life code