unit-testing

Mocking Func property of a class

Hi guys, one of my repository class (say PersonRepo) has a delegate as its property something like this private readonly Func<INameRepo> _nameRepo; and apart from this it is inherited by a class which itself expects one more object (say the session). Thus when i intialize this in my test I do something like var funcNameRepo=autoMock...

Is it common to write integration tests before writing unit tests?

Is it common to write integration tests before writing unit tests? Is it conventional, a good idea, or best practice? It just seems like a logical thing to do in my mind, especially when working with some 3rd-party API for the first time: You need to know how to use the 3rd-party software before you can test your own code for proper in...

WCF integration testing in TeamCity

I want my integration tests to run on each commit in TeamCity. What is the good way to get my WCF service running automatically for the tests? WCF service is part of the solution that is tested. Currently I self-host the service in the tests. host = new ServiceHost(typeof(...), url); But I can't apply my actual IIS configuration file...

Mocking an external API

I'm new to testing strategies and mocking, and I'm having a tough time figuring out how to mock a call to an external service. I'm sure it's something easy I'm missing, I just don't know what exactly. I'm using the Braintree gem to charge for subscription services through the Braintree gateway, and I wanted to mock the Customer create ...

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

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 ...

How to run single testcase in XCode?

I know it is best practice to run all unit testcases after any change to make sure not breaking anything. However, some times, e.g. debugging, I really want to run only one single test case. It seems XCode doesn't provide such feature in UI, while other testing framework such as JUnit has such features. Is there any workaround to have o...

How can I write tests for file upload in PHP ?

I'm using simpleTest to write my PHP tests. I'm writing a file upload plugin and was wondering how I may be testing it. I would like to check that the file is correctly uploaded, in the right folder, that error are correctly returned when needed, etc. How do I emulate a file upload (through the $_FILES variable) ? Are there any issues ...

Unit testing in Xcode doesn't work like in Apple's example

Possible Duplicate: Implementing Unit Testing on the iPhone I'm trying to follow Apple's example of how to set up unit testing... I started a new project and followed the directions. Instead of getting an error message inside the code editor (like in step 8), I get two error messages that are shown on the bottom right icon. W...

how we put dynamic input such as timestamp when using selenium plugin in firefox ?

i'm use selenium. i use it by using firefox plugin. but i have problem to utilize it. For example, i need to make a 100 post(I need them has different title, range from 1-100) without i have to copy-paste previous command and change its property value i'm sorry if my description is too vague. In nutshell, it's about how to create unit s...

Stop generation of TestResult.xml with NUnit GUI test runner

Is it possible to stop the generation of TestResult.xml when using the NUnit GUI test runner, or to change the location that it is saved to? At the moment, it is always saving to the same directory as the nunit project file, and I can't seem to alter the behaviour. (Probably brain-freeze on my part.) I am using the latest release of NU...

How to unittest a BaseHTTPRequestHandler subclass?

Since python normally takes care of instantiating these objects I'm not entirely sure how get a standalone instance of this so I can test the do_GET, do_POST, etc. methods. Any suggestions are welcome. ...

How to verify list of items in a test

I am writing a test case where I do send a list of Strings to be saved in the database. Then I will retrieve those from database and has to verify that everything is fine. I have written a assertNotNull(list) assertEquals(listSize, response.listSize()) However I want to verify the actual contents are also same. But my assertEquals ...

Unit testing facebook applications

What are good practices of unit testing facebook Canvas applications ? Lets say you have MVC application with controllers utilizing local Facebook library which provides access to Graph API, FB session. After all your application depends on facebook authentication mechanism (OAuth and Facebook Connect) thus user is required to authenti...

Can I calculate and check java project code coverage through Maven?

Possible Duplicate: How to get Cobertura to fail M2 build for low code coverage I would like to calculate code coverage of my Java code base and fail building process if any package, class, or method has code coverage of 80% or less. Is it possible to achieve with some open source tool? Preferably through a maven2 plugin. ...

Where should unit tests live?

I'm relatively new to unit testing, and I've discovered that while many sources say that you should write unit tests, few of them give any indication where to put them in your project. The only suggestions that I've seen are to put them alongside the production code or to build a directory structure that mirrors your production code. T...

Helper functions in Rails unit tests

I'm using this sort of code in my code in my Unit tests. test "should be awesome" do assert true end I'm using FactoryGirl instead of fixtures. I find that I'm repeating myself a lot and having helper functions would be quite useful. What's the best way to create and call a helper function in the unit test? Is there a before_filt...

How can I test a jasper report?

Hi, I want to test all the jasper reports of my application. I want to be able to detect: Compilation problems (Would checking that JasperCompileManager.compileReport(some inputStream) doesn´t throw JRException is a good option for this?) Filling problems (Would checking that JasperFillManager.fillReport(someReport, someParameters, so...

Is it wise to defer unit-testing until integration tests pass in scenarios where behavior of a 3rd-party API is largely unknown?

I don't mean defer all unit-testing until an integration test passes. The unit tests I'm referring to are those that verify that the SUT interacts with the 3rd-party mystery API correctly. The rationale for deferring these unit tests is that they verify something that is unknown. If I don't know how the 3rd-party mystery API works, ho...

How can I mock an internal interface using NMock2?

If I try this, I just get an exception: System.TypeLoadException : Access is denied: 'Namespace.IInternalInterface'. Making the interface public is not an acceptable solution. I don't want to change the visiblity of my API in order to test it. ...

Spring/Hibernate testing: Inserting test data after DDL creation

I have a Spring/Hibernate webapp that has some integration tests that run on an in-memory HSQL database. Hibernate takes this blank database and creates all of my test tables and constraints thanks to hbm2ddl=create. However, I have a new bean that checks for a particular config value from the database during its afterPropertiesSet() m...