unit-testing

How to rewrite data-driven test suites of JUnit 3 in Junit 4?

I am using data-driven test suites running JUnit 3 based on Rainsberger's JUnit Recipes. The purpose of these tests is to check whether a certain function is properly implemented related to a set of input-output pairs. Here is the definition of the test suite: public static Test suite() throws Exception { TestSuite suite = new Test...

Identifying which tests provide coverage in VS2010 code coverage results

Does anyone know of an easy way to work backwards from the VS2010 code coverage in-file highlighting to the test that provides the coverage? I have a file with one method covered and another not but looking through my tests I can't spot the one providing the current coverage. It would be great to be able to navigate back from the code hi...

Qt, unit testing and mock objects.

Hello. Qt framework has internal support for testing via QtTest package. Unfortunately, i didn't find any facilities in it that can assist in creating mock objects. Qt signals and slots offers a natural way to create a unit-testing friendly units with input (slots) and output (signals). But is it any easy way to test that calling specif...

Unit test approach for generic classes/methods

Hi, What's the recommended way to cover off unit testing of generic classes/methods? For example (referring to my example code below). Would it be a case of have 2 or 3 times the tests to cover testing the methods with a few different types of TKey, TNode classes? Or is just one class enough? public class TopologyBase<TKey, TNode, ...

Hyperlinks in VS2008 Test Result Details

In case when resulting string in "Test Result Details" (TRD) is very long, the Visual Studio 2008 crashes. I fixed this by sending the result data into a file. There is a problem, however, because there isn't a simple way to open such file. Of course, I can manually open folder and then the file, but it isn't very efficient. Now, to the ...

How to perform Unit Testing for Business Objects in asp.net

Unit Testing for Business Object ...

Testing a method that sends e-mail without sending the mail

I have a method like public abstract class Base { public void MethodUnderTest(); } public class ClassUnderTest : Base { public override MethodUnderTest() { if(condition) { IMail mail = new Mail() { /* ... */ }; IMailer mailer = new Mailer() { /* ... */ } mailer.Send(mail)...

When mocking a class with Moq, how can I CallBase for just specific methods?

I really appreciate Moq's Loose mocking behaviour that returns default values when no expectations are set. It's convenient and saves me code, and it also acts as a safety measure: dependencies won't get unintentionally called during the unit test (as long as they are virtual). However, I'm confused about how to keep these benefits when...

ASP.NET MVC - How to Unit Test boundaries in the Repository pattern?

Given a basic repository interface: public interface IPersonRepository { void AddPerson(Person person); List<Person> GetAllPeople(); } With a basic implementation: public class PersonRepository: IPersonRepository { public void AddPerson(Person person) { ObjectContext.AddObject(person); } public List<...

How do I create a unit test that updates a record into database in asp.net

How do I create a unit test that updates a record into database in asp.net ...

How to unit test synchronized code

Hi, I am new to Java and junit. I have the following peice of code that I want to test. Would appreciate if you could send your ideas about what's the best way to go about testing it. Basically, the following code is about electing a leader form a Cluster. The leader holds a lock on the shared cache and services of the leader get resum...

Silverlight Unit tests can't be run (using ReSharper or NUnit): dependency error appears

CThru.Silverlight can't find dependent libraries Typemock.Isolator.VisualBasic & Typemock.ArrangeActAssert of Version=6.0.2.0 but there are versions 6.0.3.0 of these libraries registered. Any workaround? Where to download Typemock 6.0.2.? TIA ...

Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?

I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following: IUtilisateur IGroupe IUniteOrganisation These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This ...

NHibernate How to specify custom sql type only in production

I am saving binary files into a Sql Server 2005 Db using Fluent NHibernate. However, I am using SQLite to run my (pseudo) Unit Tests. I need to use a custom Sql type for Ms Sql, but it would throw an error on SqlLite. What strategies can I use? This is the Map file: public class BinaryFile { public BinaryFile() { ...

Unit Testing using InternalsVisibleToAttribute requires compiling with /out:filename.ext?

In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?, I was asking about InternalsVisibleToAttribute. I have read the documentation on how to use it, and everything is fine and understood. However, I can't instantiate my class Groupe from my Testing project. I want ...

how to start multiple instance of an application in a test

Hi I m working on a client-server program, where there is no test at all. When i try to do some test with two server, it's look like both server is connected to the same database. I think the reason is some bad use of static field. So i wonder, is there a way to start two VM in a junit test? ...

FlexUnit - howto check label text

I am trying to automatically verify certain conventions, such as label/table column header text (Sentence Case, use of colons, etc). It would be nice if there was a way in FlexUnit, or other means, to Iterate over all views in the app Get all titles, labels, column headers Run some pattern checks and fail where needed. Does anyone...

How to know if your Unit Test is "right-sized"?

One thing that I've always noticed with my unit tests is that they get to be kind of verbose; seeing as they could also be not verbose enough, how do you get a sense of when your unit tests are the right size? I know of a good quote for this and it's: "Perfection is achieved, not when there is nothing left to add, but when there...

How to know if your Unit Test Fixture is “right-sized”?

How do you know if you "Test Fixture" is right-sized. And by "Test Fixture" I mean a class with a bunch of tests in it. One thing that I've always noticed with my test fixtures is that they get to be kind of verbose; seeing as they could also be not verbose enough, how do you get a sense of when your unit tests are the right size? My ...

Entity framework unit testing with sqlite

Is it possible to unit test Entity Framework v2 repositories with SqLite? Is this only possible if my entities are plain Poco and not automatically generated by Entity Framework? I've generated a entity model from SqlServer and in the generated .edmx file i found this in section SSDL content: Provider="System.Data.SqlClient". Correct me...