unit-testing

When debugging unittest in visual studio the debugsession just quits

I've had this occur to me daily now. I am debugging my libraries using unittests. My libraries are all code projects inside a single solution. So I'm stepping through the code and all of a sudden it just continues as if I would've pressed F5, which I didn't. Is this a bug or is there something I'm missing here? Anyone else experiencing...

how to do unit testing of functions writing files using python unittest

I have a python function that writes an output file to a disk. I want to write a unit test for it using python unittest module. How should I assert equality of files? I would like to get an error if the file content differs from the expected one + list of differences. As in the output of unix diff command. Is there any official/recomm...

Buildbot parsing Python Unit test results

I have a test suite that outputs test results in the Python Unit Test format: http://docs.python.org/library/unittest.html Is there an existing Buildbot module/plugin that can parse this form? Example: DigitalReadWrite_02 ... ok DigitalReadWrite_03 ... ok...

Python unittests almost never check types

I was going through a few tests written in Java using JUnit and I could'nt help noticing the emphasis which is laid on checking the "type" of objects. This is something I have never seen in Python test-suites. Java being statically-typed and Python being dynamically-typed, should'nt the reverse be the case? ...

.net mvc2 custom HtmlHelper extension unit testing

My goal is to be able to unit test some custom HtmlHelper extensions - which use RenderPartial internally. http://ox.no/posts/mocking-htmlhelper-in-asp-net-mvc-2-and-3-using-moq I've tried using the method above to mock the HtmlHelper. However, I'm running into Null value exceptions. "Parameter name: view" Anyone have any idea?? Tha...

importing fixture data from mysql

Is there anyway to import data using mysqldump rather than fixtures during a test (rake test:profile in this case). I have not been successful in exporting mysql data in yml format (which works ok) and importing it into rails (doesn't work, rake task complains about formatting of the yml file whose integrity seems intact). What are som...

Pythonic equivalent of ./foo.py < bar.png

I've got a Python program that reads from sys.stdin, so I can call it with ./foo.py < bar.png. How do I test this code from within another Python module? That is, how do I set stdin to point to the contents of a file while running the test script? I don't want to do something like ./test.py < test.png. I don't think I can use fileinput, ...

How many open files in PHP?

Is there a function in PHP to query the number of open files? Sort of like memory_get_usage() but for open files. I'm running the unit test suites for Zend Framework. The problem is that after it gets through the tests for Zend_Search_Lucene, subsequent tests start failing. But if I skip the Zend_Search_Lucene tests, all the test s...

No intellisense in Visual Studio 2010 Test Projects

Is there anything special about Test Projects that would cause intellisense not to work? This is my first experience with a test project. ...

NoClassDefFoundError when trying to unit test JSON parsing in Android

I'm working on an Android app where some part of it gets JSON-formatted data from a web service. The basics of the class parsing the JSON data looks like this: public class JsonCourseParser implements CourseParser { public Course parseCourse(String courseData) { Course result; try { JSONObject jsonObject = new JSONObject(cour...

unit testing code which uses JPA & JTA

I use 2 separate database, so i have to use JTA to handle distributed transactions.So either either both db have to commit or both rollback. I use open JPA and JTA.Now to unit test the code using junit ? I get the following error when i try to run my code which handles distributed transcations.I had posted similar question on this sit...

Unit testing date sensitive functions?

I am trying to write tests for a date helper class. I am wondering what is best practice for this. Here is an example in PHP. public static function get_date($offset = 0){ $date = mktime(0, 0, 0, date('m') , date('d') + $offset, date('Y')); return array( 'day' => date('D',$date), 'month' =...

Database Unit-Testing. What is the best database testing approach for enterprise solution running CI, having branches and heavy databases?

So situation is following: We have some very old product, that has dozen of solutions. Many of them run different unit tests, some MSTest, some NUnit. There are lot of tests that test database, also some depend on data. In other words they execute code to check if customer Andriy has orders with products A and B. I know that this is wron...

How can i unit test a "Delete link" with Ror, cucumber - webrat ?

Hello, I am currently developing a Rails application, I'm trying to units test it. I chose Cucumber + WebRater. I'd like to test in my backend all delete link. I tried to go to visit a second argument (the method: delete) without success. (something like : visit my_path, method => :delete) On my pages I delete some links so the soluti...

How to test a returned array contains at least one value with a certain property value

Hi, say I have a method I wish to test: public Cars[] GetCars(); I want to test that the array returned by this method contains at least one car which is of type "Mustang". How would I actually do this? Currently I have code like: [Test] public void GetCars_ReturnsMustangs() { Cars[] cars = GetCars(); foreach(Car car in cars...

Is the order of the two parameters in Assert.AreEqual(expected, actual) important?

I wonder if the order is important? What do you think? ...

Please review my test architecture (in memory database)

I've just started with unit testing, and would like to know if I'm on the right track. Can you guys please take a look at my code and tell me what you think if it? This is the (basic) method that I want to test: public void Accept(long resumeId) { // Get the resume that has to be accepted Resume originalResume = ResumeDAC.GetById...

What does `DeploymentItem` attribute mean?

Let's say we have a short program: namespace ConsoleTryIt { static class Program { static void Main(string[] args) { var sum = Add(1, 2); } private static int Add(int p, int p2) { return p + p2; } } } When create the unit test class for this class, Vi...

How to serialize to c# code?

I am testing a web-service that gets an object as a parameter. To create this object I go through an online store that we are maintaining and the end result is a rather big object, we can call it BO, sent to a web-service. Now we seem to have a bug that comes up when BO is in a specific state. I tediously go through the online store t...

Difference between add to target & add to project in XCode

I am trying to inegerate Google Toolbox for mac for unit testing purposes on this page http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting is says add blahblah.m file to your target & add blahblah.m file to your project. What is the difference, how should I add to target... ...