unit-testing

Junit throw warning while still passing test

I'm working on a project at the moment that we're using junit to test, but as its still fairly early stages a lot of features aren't yet implemented, though they already have tests written for them this means these tests (obviously) always fail I was wondering if anyone knew a way to get JUnit to pass the test while displaying a warnin...

running a subset of JUnit @Test methods

We're using JUnit 4 to test: we have classes that don't are a subclass of TestCase, and they have public methods annotated with @Test. We have one file with many @Test methods. It would be nice to be able to run a subset of them via Ant from the command line, in the style of this recipe for JUnit 3: ant runtest -Dtest=MyTest -Dtests=tes...

How can I disable Microsoft.VisualStudio.TestTools.TestTypes.Unit.TestFailedException

I want to disable the Microsoft.VisualStudio.TestTools.TestTypes.Unit.TestFailedException when I am debugging my unit tests. The problem is when I open the Exceptions dialog in Visual Studio I can't find this Exception. Does anyone know how to stop this exception from being thrown? ...

Moq and virtual properties and methods

I'm using Moq for unit testing. It order for Moq to work, properties and methodes have to be marked as virtual. Sometimes I pass in data and set property values in the constructors. Isn't there a rule that you should not set virtual properties in constrcutors since it might cause unexpected behaviour (if the class has been inherited from...

There are some things you just can't test!?

When unit testing, it is always hard to know how low down to the framework you go. If we have a class that directly depends on the .NET Framework, i.e. the System.IO.File class, then we cant really test that in isolation. Sure we could wrap it and inject it into the dependent class, but then we start to wrap every .NET class! What...

Best way to test for databases/connections

Is there a way to unit-test classes wich require database connections? e.g. User-Classes (DB-)Object mocking didn't quite help ...

How to execute JUnit and TestNG tests in same project using maven-surefire-plugin ?

Right now I have both type of tests but when I say "mvn test" it only executes TestNG tests and not Junit. I want to execute both one after another. Any Idea ? ...

How could I refactor this factory-type method and database call to be testable?

I'm trying to learn how to do Unit Testing and Mocking. I understand some of the principles of TDD and basic testing. However, I'm looking at refactoring the below code that was written without tests and am trying to understand how it needs to change in order to make it testable. public class AgentRepository { public Agent Select(in...

testing hibernate parent/child relationship

hello good fellas! i use spring and hibernate for my data access layer i'll like to have some guidance about how to construct my unit testing to test if hibernate is effectively insert in the child table(parent hibernate mapping has the cascade all on the set). For what i know i shouldn't mix dao's unit testing.So supposing the i'm testi...

Trace in Visual Studio Testing (Migrating from NUnit)

In NUnit, I'm used to writing Trace statements in the test, and having them show up in the trace tab of the NUnit gui. On a new project, I'm moving to the built in Unit Testing in Visual Studio Professional Addition, which I believe is an interface to mstest.exe. Test Code: <TestMethod()> Public Sub TestPagesInheritFromBasePage() ...

Subsonic 3 ActiveRecord Test Feature Doesn't Support Linq?

According to this blog post, the ActiveRecord Test features in Subsonic 3 don't support linq. If this is true, it would seem to really constrain the usefulness of the Test features. Is there a workaround, or am I just misreading what was said? ...

Unit Testing for VBScript, ASP Code and SQL Server 2000

I have a very old project implemented in (classic) ASP and SQL Server 2000. Because of quality concerns, I've been considering the possibility of implementing some form of automated quality testing. Though, the web pages are ASP the project is really 85% SQL Server stored procedure, functions, views and DTS. (Lots of dependency on DTS) ...

Using Jeremy Mcanally's context for testing in Rails 2.3.x

I'd like to try out Jeremy Mcanally's context gem for testing: http://github.com/jeremymcanally/context/tree/master It does not work out of the box with Rails 2.3.x, anyone got it working? EDIT hi mike, tx for ur help. i installed the gem like u said, and have added "require 'context'" to test_helper.rb however, it stil doesn't seem t...

Pass Function value to Stored Procedure in MS SQL

I have a Function called dbo.GetFoo(). I also have a unit-testing Stored Procedure called AssertEqual (which takes @TargetValue sql_variant, @ExpectedValue sql_variant, and @Message varchar) I want to call GetFoo() and check to see if it's returning the right value 'X'. My T-SQL statement is: exec AssertEqual dbo.GetObjectType(), 'S', ...

LINQ to SQL: Fake Repository with Many-to-Many Relationships?

I have two tables, Clients and Administrators, which are linked in a many-to-many relationship by the table ClientAdministrators. In the real application this works fine and I can get a list of Administrators for my Client. My problem comes in trying to unit test the service class that is retrieving this from the repository. I have a ...

Writing a single unit test composed of multiple test cases violates unit testing principles?

Should I do Test1(){ Assert(TestCase1); Assert(TestCase1); Assert(TestCase3); ... } or Test1(){ Assert(TestCase1); } Test2(){ Assert(TestCase2); } Test3(){ Assert(TestCase3); } ... Note: All test cases are intimately related. There is only boolean differences between them. ...

Which unit testing framework do you use for Symfony?

Which unit testing framework do you use for Symfony? Lime or PHPUnit? What are the pros and cons of using them? ...

Mocking PHP functions in unit tests

I'm unit-testing some PHP code with SimpleTest and I've run into trouble. In my tests of a database class I want to be able to set an expectation for PHPs mysql functions. In my tests of a wrapper class for the mail function I want to mock PHPs mail function. These are just some examples. The point is: I don't (always) want to test if m...

I do not write tests. Am I stupid?

I've done a little bit of reading on unit testing and TDD, and I've never seriously considered writing tests to such a precise extent. Granted, I am not working on any projects that are ridiculously huge. If all I build are small apps, am I stupid for not writing tests? Edit: To clarify, when I say "small apps", I mean apps that are ...

Running Visual Studio 2008 C# (MSTest.exe based) unit tests in Mono

Hello, I'm using VS2008 to develop a project that I'm starting to test under Mono. There are a number of unit tests written using the VS unit test framework, is there a tool that will let me run these in Mono? Thanks, ...