unit-testing

using results of multi-table SELECT to populate test database? (SQL Server 2005)

I was wondering if there were techniques or tools out there that would let me take a multi-table SELECT statement, complete with inner and outer joins, and determine after running it exactly which rows in each table are required to make the same SELECT return the identical rowset in a mini version of the database? The ideal would be to ...

Testing classes with threads, events, and private methods

hey guys general consensus I've done quite a lot of reading up on the subject of testing complex classes and private methods. The general consensus seems to be: "if you need to test private methods then you're class is badly designed" "if your class is complex, then you need to separate it out" So, I need your help. the problem C...

Why is [AssemblyInitialize] and [AssemblyCleanup] being called twice in same test project assembly?

I though the whole purpose of these attributes was to run them only once per assembly. I have a simple class as follows: [TestClass] public class AssemblyIntegrationTestSetup { public AssemblyIntegrationTestSetup() { } public TestContext TestContext { get; set; } [AssemblyInitialize] public static void SetupIntegrationT...

Activation error occured while trying to get instance of type Database, key "" <-- blank

I'm trying out the Enterprise Library 5.0 and was doing some unit-tests on my BL, do I need to have a app.config on the DL or on the Test project? note: I already have the configuration settings on my web.config on my web project. how I use the DAAB: private static Database db = DatabaseFactory.CreateDatabase(); db.ExecuteNonQuery("s...

Integration testing web services against a testing database

I'm currently building a .net web application that uses WCF web services to allow a Flex front end to access the database. I'm in the process of setting up some unit/integration style testing on the web services and am trying to work out the best way to allow the tests to access and modify data in a separate test database. Currently, t...

.net testing app

i'm using vs2010's standart unit tests, for example, i want to get all information like used variables with their values, called functions, etc. in readable form, xml forexample. how can i do it? ...

Can't use flash in ActionView::TestCase when I want to test my helper class

I wanted to test a method in my helper class but when I do something like: require 'test_helper' class ApplicationHelperTest < ActionView::TestCase def test_flash_messages flash[:notice] = "Hello World" assert_equal "<div class=\"message-notice\">Hello World<\/div>", flash_messages end end than I get "NoMethodError: undef...

How to build Exception Logger system in PHP that can have different Logger implementations e.g. File/DB and is testable

I'm building a PHP library that throws various custom Exceptions when it encounters errors. I need to log those exceptions and provide various implementations of the Logger so they could be logged in a file or a database. The exceptions need to be logged whether they are caught or not, so that excludes implementing any of this in a cust...

Possible to unit test code that wasn't initially design to be tested, without changing any code?

Is it generally accepted that you cannot test code unless the code is setup to be tested? A hypothetical bit of code: public void QueueOrder(SalesOrder order) { if (order.Date < DateTime.Now-20) throw new Exception("Order is too old to be processed"); ... } Some would consider refactoring it into: protected DateTime M...

How to write a unit test for "T must be a reference type"?

Consider: class MyClass<T> where T : class { } In that case, the where clause is enforcing a specification that MyClass is only a generic of a reference type. Ideally I should have a unit test that tests this specification. However, this unit test obviously won't work, but it explains what I'm trying to accomplish: [Test] [DoesNotC...

ASP.NET MVC 3 beta: TryUpdateModel throws NullreferenceException in unit test

Hi, Since I updated to ASP.NET MVC 3 Beta 1, I get a NullReferenceException whenever I call TryUpdateModel() during a unit test session. The stack trace looks like this: Execute System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(Con...

Including visibility of options menu in Android Unit Test

I've search for a while now, but I can't find any answers on this topic. So, i've been trying to include UI tests into my suite. But I can't figure out how to check if a certain menu item on the options menu for an activity is visible after I sent a certain series of keys to the emulator. Is it possible to get a handle to the options m...

Connection Issue while using Jasmine Javascript Testing Framework

I am having an issue using Jasmine on Ubuntu when trying to run the example javascript specs through Selenium using the "rake jasmine:ci" command. I will periodically get a "Connection refused" error when net/http is trying to connect to the port where Selenium is running. An example the start of the backtrace I get is: Waiting for jasm...

Moq: Setup a property without setter?

Hi, I have following class: public class PairOfDice { private Dice d1,d2; public int Value { get { return d1.Value + d2.Value; } } } Now I would like to use a PairOfDice in my test which returns the value 1, although I use random values in my real dice: [Test] public void DoOneStep () { var mock = new Moc...

How do I test my plug-in interface which uses an abstract class?

I'm using PHP 5.3 and SimpleTest, but more general answers are welcome. Each plug-in will be a class which extends an abstract class... how do I test that this interface works properly? Do I have to create several plug-ins and test them? Or is there a more satisfying way? As an example, imagine writing something to represent money. User...

Why the 'Moq.Proxy.CastleProxyFactory' type initializer exception when using NET40-NoCastle?

So I copied the sample code from the Moq home page pretty much verbatim, and am getting a castle proxy exception. Here's my code (as a console app for an easier sample) using System; using System.Collections.Generic; using System.Linq; using System.Text; using Moq; namespace MoqTestConsole { public interface ILoveThisFramework ...

Testing in leiningen

I am writing a small Clojure project using leiningen with the following directory structure: project + src + org/example/project/core.clj + test + org/example/project/core.clj When I run lein test, it reports that it ran 0 tests with 0 failures, but I purposely put a test designed to fail in the test/.../core.clj file. I added th...

System.Web.Security.MembershipCreateStatus not accessable from a Test project?

Hello, I coded a custom Membership provider and I want to run some Unit tests against it. However, whenever I create a "Test" project, I can't access MembershipCreateStatus. You may know that this is a type on an out parameter for CreateUser. I am using VS2010 Ultimate and just can't seem to grasp why, even when I add a reference to ...

Automated testing of CSS and HTML front-end coding

I'm a front-end developer coding CSS, HTML and Javascript (in that order) and most of the work I do is design-lead. Whilst the quality of the designs I create with CSS is subjective, much of the coding is purely functional / layout and I am interested in any way to automate the testing of my page. My question can be split into two part...

Making a DynamicMock MockInstance equal to itself

Trying to use NUnit to test a method that adds an object to a queue, and throws an exception if the object's already been queued, but it fails because Queue.Contains() can't detect that the mock object's already in the queue. The method under test is pretty simple: public void Enqueue(ISomeInterface obj) { if (myQueue.Contains(obj)...