tdd

NSURL to file path in test bundle with XCTest

倾然丶 夕夏残阳落幕 提交于 2019-11-29 22:37:16
I am trying to write an iOS app using TDD and the new XCTest framework. One of my methods retrieves a file from the internet (given a NSURL object) and stores it in the user's documents. The signature of the method is similar to: - (void) fetchAndStoreImage:(NSURL *)imageUrl I'm trying to write the test for this method in a way that it doesn't fail if there is no connection to the internet. My approach (taken from a previous question ) is to call the method using a NSURL to an image in the local file system. When a new project with unit tests enabled is created, the Tests directory has a

How to learn TDD with Ruby?

五迷三道 提交于 2019-11-29 22:20:41
I have been using ruby exclusively for about a month and I really love it. However, I am having an incredibly hard time using, or even learning TDD. My brain just doesn't function that way... I really, really want to learn TDD but to be honest I am a bit confused. All the articles that I find when Googling around are mostly specific to Rails, which is not interesting to me because I want to learn how to do efficient testing for any ruby application, from the simple one-file script to the complicated gem, not for Web apps. Also, there are so many frameworks and so few tutorials to get started.

How can I unit test my ASP.NET MVC controller that uses FormsAuthentication?

被刻印的时光 ゝ 提交于 2019-11-29 21:15:40
I'm working with a ASP.NET MVC solution in a test driven manner and I want to login a user to my application using forms authentication. The code I would like to end up with in the controller looks something like this: FormsAuthentication.SetAuthCookie(userName, false); My question is how do I write a test to justify this code? Is there a way to check that the SetAuthCookie method was called with the correct parameters? Is there any way of injecting a fake/mock FormsAuthentication? Darin Dimitrov I would start by writing an interface and a wrapper class that will encapsulate this logic and

Cuke4Nuke or SpecFlow?

两盒软妹~` 提交于 2019-11-29 20:53:51
I am trying to decide if I should use Cuke4Nuke or SpecFlow. What are the pro/cons of each? Opinions on which is better and why. Thanks! (I might be biased because I am involved with SpecFlow, but here my thoughts...) Cuke4Nuke is very close to Cucumber. This promises a lot of advantages: Compatibility Getting new features from Cucumber when Cucumber evolves (at least in theory, but language support is an example for this) Being a real part of the Cucumber community and the Cucumber ecosystem However this comes also with some potential disadvantages: Ruby is a necessity Since more

Does Test Driven Development take the focus from Design? [closed]

丶灬走出姿态 提交于 2019-11-29 20:11:54
I have mixed feelings about TDD. While I believe in testing I have a issues with the idea of the test driving my development effort. When you code to satisfy some tests written for an interface for requirements you have right now, you might shift your focus from building maintainable code, from clean design and from sound architecture. I have a problem with driven not with testing. Any thoughts? No. If done right, Test Driven Development IS your design tool. I hope you forgive me for linking to my own blog entry, wherein I discuss the pitfalls of Test Driven Development that went wrong simply

What not to test when it comes to Unit Testing?

风格不统一 提交于 2019-11-29 20:08:00
In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp? If there is an answer to this question then %100 coverage is a myth, isn't it? Here I found (via haacked something Michael Feathers says that can be an answer: He says, A test is not a unit test if: It talks to the database It communicates across the network It touches the file system It can't run at the same time as any of your other unit tests You have to do special things to your environment (such as editing config files) to run it. Again in same article he adds: Generally, unit tests are

The Agile Way: Integration Testing vs Functional Testing or both? [closed]

六月ゝ 毕业季﹏ 提交于 2019-11-29 20:07:55
I work in an office which has been doing Agile for a while now. We use Scrum for project management and mix in the engineering practices of XP. It works well and we are constantly learning lessons and refining our process. I would like to tell you about our usual practices for testing and get feedback on how this could be improved: TDD: First Line of Defense We are quite religious about unit testing and I would say our developers are also experienced enough to write comprehensive tests and always isolate the SUT with mocks. Integration Tests For our use, integration tests are basically the

How to write good Unit Tests? [closed]

对着背影说爱祢 提交于 2019-11-29 19:43:47
Could anyone suggest books or materials to learn unit test? Some people consider codes without unit tests as legacy codes. Nowadays, Test Driven Development is the approach for managing big software projects with ease. I like C++ a lot, I learnt it on my own without any formal education. I never looked into Unit Test before, so feel left out. I think Unit Tests are important and would be helpful in the long run. I would appreciate any help on this topic. My main points of concern are: What is a Unit Test? Is it a comprehensive list of test cases which should be analyzed? So lets us a say i

Developing UI in JavaScript using TDD Principles

强颜欢笑 提交于 2019-11-29 19:26:22
I've had a lot of trouble trying to come up with the best way to properly follow TDD principles while developing UI in JavaScript. What's the best way to go about this? Is it best to separate the visual from the functional? Do you develop the visual elements first, and then write tests and then code for functionality? Kris Gray I've done some TDD with Javascript in the past, and what I had to do was make the distinction between Unit and Integration tests. Selenium will test your overall site, with the output from the server, its post backs, ajax calls, all of that. But for unit testing, none

How do you unit test a unit test? [closed]

﹥>﹥吖頭↗ 提交于 2019-11-29 18:50:19
I was watching Rob Connerys webcasts on the MVCStoreFront App, and I noticed he was unit testing even the most mundane things, things like: public Decimal DiscountPrice { get { return this.Price - this.Discount; } } Would have a test like: [TestMethod] public void Test_DiscountPrice { Product p = new Product(); p.Price = 100; p.Discount = 20; Assert.IsEqual(p.DiscountPrice,80); } While, I am all for unit testing, I sometimes wonder if this form of test first development is really beneficial, for example, in a real process, you have 3-4 layers above your code (Business Request, Requirements