unit-testing

C# unit test code questions

We start use C# build-in unit test functionality. I have VisualStudio 2008 created unit test code for me. I have few question above the generated code. Following are code I copied from the generated file: #region Additional test attributes // //You can use the following additional attributes as you write your tests: // //Use ...

C# unit test code questions continue

more questions after questions in here: http://stackoverflow.com/questions/2714073/c-unit-test-code-questions I found the VS unit test testframe treat private and protected method in the same way but deferent from public method. The following is the generated code for a private method: /// <summary> ///A test for recor...

Unit Testing Example, on a class with required fields?

I'm new to developing Unit test and I can't find an example of how to test an existing class I have. The class has a save method which does an insert or update in the database when the user clicks Save in the UI. But the save method has required fields that need to be populated. And has other fields that do not. So how can I run this t...

VS.Net Unit Testing -- possible to have project-scoped test setup?

Within a test file (MyTest.cs) it is possible to do setup and teardown at the class and the individual test level. Do similar hooks exist for the entire project? Entire solution? ...

How can I change a connection string, or other app settings, at test time in Visual Studio 2008?

I need to test a class library project in VS. This project, itself, does not have a web.config file, but the classes do on the web server to which it's deployed. I access these like this: ConfigurationManager.ConnectionStrings["stringname"].ConnectionString; Can I adjust these strings while running unit tests in VS? Should I have cons...

Unit testing ASP.NET MVC 2 routes with areas bails out on AreaRegistration.RegisterAllAreas()

I'm unit testing my routes in ASP.NET MVC 2. I'm using MSTest and I'm using areas as well. [TestClass] public class RouteRegistrarTests { [ClassInitialize] public static void ClassInitialize(TestContext testContext) { RouteTable.Routes.Clear(); RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ...

What are the best practices for unit testing properties with code in the setter?

I'm fairly new to unit testing and we are actually attempting to use it on a project. There is a property like this. public TimeSpan CountDown { get { return _countDown; } set { long fraction = value.Ticks % 10000000; value -= TimeSpan.FromTicks(fractio...

How do you unit test new code that uses a bunch of classes that cannot be instantiated in a test harness

I'm writing a messaging layer that should handle communication with a third party API. The API has a bunch of classes that cannot be easily (if at all) instantiated in a test harness. I decided to wrap each class that I need in my unit tests with an adapter/wrapper and expose the members I need through this adapter class. Often I need to...

SQLite assembly not copied to output folder for unit testing

Problem: SQLite assembly referenced in my DAL assembly does not get copied to the output folder when doing unit tests (Copy local is set to true). I am working on a .Net 3.5 app in VS2008, with NHibernate & SQLite in my DAL. Data access is exposed through the IRepository interface (repository factory) to other layers, so there is no nee...

Are there any open source SimpleTest Test Cases that test PHP SPL interfaces

I have quite a few objects in my system that implement the PHP SPL Iterator interface. As I write them I also write tests. I know that writing tests is generally NOT a cut 'n paste job. But, when it comes to testing classes that implement Standard PHP Library interfaces, surely it makes sense to have a few script snippets that can b...

what is the best tool for unit test in VB?

have to check some formulae whether they are providing correct result, these formula are written part of a VB program, what is the best tool\method to unit test these formula? ...

How To Unit Test An Application Updater

How would you Unit Test the update process of an application? I have an application and now I'm writing my own Update module for it (using MVVM) which is a separate EXE. What is the best way to structure this module so that it will be possible to unit test. ...

Database testing in python, postgresql

How do you unit test your python DAL that is using postgresql. In sqlite you could create in-memory database for every test but this cannot be done for postgresql. I want a library that could be used to setup a database and clean it once the test is done. I am using Sqlalchemy as my ORM. ...

Using content from the project in tests

I am working with Visual Studio 2010 and it's integrated testing functionality. I have an XML file in my project which is set to copy to the output directory. I can access the file just fine when I compile and run the project. But it doesn't exist when I attempt to access it within a TestMethod. It looks like the test is run with the ...

How to write a jUnit test for this class?

Hi, I would like to know what's the best approach to test the method "pushEvent()" in the following class with a jUnit test. My problem is, that the private method "callWebsite()" always requires a connection to the network. How can I avoid this requirement or refactor my class that I can test it without a connection to the network? c...

Sensible unit test possible?

Could a sensible unit test be written for this code which extracts a rar archive by delegating it to a capable tool on the host system if one exists? I can write a test case based on the fact that my machine runs linux and the unrar tool is installed, but if another developer who runs windows would check out the code the test would fail,...

How can I know when SQL Full Text Index Population is finished?

We are writing unit tests for our ASP.NET application that run against a test SQL Server database. That is, the ClassInitialize method creates a new database with test data, and the ClassCleanup deletes the database. We do this by running .bat scripts from code. The classes under test are given a connection string that connects to the ...

XCode 3.2 does not mark unit test assert failures in the editor

I've been off in Java land for about a month or so and now, upon returning to XCode I feel lost. I've upgraded 1st to 3.1.2 then recently to 3.2 and also got a new Mac with Snow Leopard so I'm not exactly sure when the problem surfaced. I just know that I used to get little red bubbles in my unit test next to the failing asserts and that...

Unit test tools for iPhone development with Xcode

When developing iPhone apps with Xcode 3.2.1/Objective C, which unit test tools are recommended? I am new to the iPhone OS platform, and I am interested in your best practices. ...

C# why datetime cannot compare?

my C# unit test has the following statement: Assert.AreEqual(logoutTime, log.First().Timestamp); Why it is failed with following information: Assert.AreEqual failed. Expected:<4/28/2010 2:30:37 PM>. Actual:<4/28/2010 2:30:37 PM>. Are they not the same? EDIT Use this if you only care to second: Assert.AreEqual(logoutTime.ToStri...