unit-testing

Fluent NHibernate unit tests

Say I've written a custom membership provider which extends System.Web.Security.MempershipProvider. This sits in its own project. overriding the ValidateUser method looks like this: IList<User> Users; using (ISession sess = NHibernateHelper.GetCurrentSession()) { Users = sess.CreateQuery("select u from User ...

How to output log in MS Unit Testing Framework VS 2010

Hi, I am trying to log some information while the unit test is running in MS Unit Testing Framework VS 2010. I tried Trace.WriteLine, Console.WriteLine and Debug.WriteLine but I am not able to see the output in the output window. Any idea how to do it? Thanks in advance ...

why do i have to rebuild the test project, whenever i change the code ??

I have visual studio 2010, and a unit-test project. when i run (debug test in the current context),then stop it,and then change the code, i have to rebuild the project, otherwise the project will run without debugging, and it will use the old code !!! why is that happening ? ...

Automating unit tests for asp.net mvc

Today I finally started to write some unit tests for my new ASP.net MVC project seriously. Some unit tests, however, kept returning for every action in a each controller: Perform a test whether the returned ActionResult is not null. Perform a test whether the action returns a valid ActionResult if the ModelState is invalid. Perform a t...

C# unit testing number precision questions

I am testing basic math functions that'll return its mean/variance/standard deviation. The problem I am facing is that I cannot get the precision of "expected value" to math what is returned by the function. For example, if the variance function returns 50.5555555555566, even if I set the expected value explicitly to 50.5555555555566, it...

running fsUnit tests from visual studio

So i wrote my first fsUnit test in Visual studio. It is just an extension to the NUnit framework and I have been using NUnit from doing TDD in C#. While writing tests in c#, I am able to run the tests from visual studio But I am not able to run f# tests from VS. why is this ? Are there any other tools which i can use to run the tests (ex...

JUnit java.lang.NoSuchMethodError: junit.framework.ComparisonFailure.getExpected()Ljava/lang/String

I am getting the following exception from a test case that ran successfully before but now it throws this exception: java.lang.NoSuchMethodError: junit.framework.ComparisonFailure.getExpected()Ljava/lang/String; at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:63) at org.junit.runn...

Recording website load times?

I am trying to record the time it takes to load my website on an average (say 10 runs) from various locations in the world. For this, I was thinking of using a list of proxies to achieve this and am not sure this is the perfect way of doing this. Is there a Firefox add-on that lets me time this perhaps using Firebug itself? Is there a...

Is it possible to create a stub for UIImagePickerController?

I am trying to write unit tests for a class that manages a UIImagePickerController. Yet, I still would like to link against UIKit to pull in other symbols I don't care about stubbing. Usually, I use OCMock for mocking out instance methods. With UIImagePickerController I'm interested in mocking out class methods which OCMock can't do. I'...

Mock Verify/VerifyAll before or after Assertion

Hi All, I have been used to following code pattern while writing my test public void TestMethod_Condition_Output() { //Arrange---------------- Mock<x> temp = new Mock<x>(); temp.setup....... //Act-------------------- classinstance.TestMethod() //Assert------------------ temp.VerifyAll(); Assert.AreNot...

Rhino Mock OfType<>

Hi, Im trying to test this statement IStudentAssessmentUnitStatus res = student.UnitStatusList.OfType<IStudentAssessmentUnitStatus>(). FirstOrDefault(s => s.ID == unit.ID); Inside the list there could be multiple types hence the OfType. However when testi...

Testing tutorial and interview questions

Can anyone provide me Tutorial documents for Testing and interview questions for Testing based on Fresher level and experience level ? ...

How to type into input field with WicketTester?

I'm writing a unit test for a Wicket WebPage. I want to fire up a page, type into a field, click a link, and then make some assertions. Looking at the API of WicketTester and BaseWicketTester, I couldn't find any method that takes a path (like "form:input") to locate an input field and lets you enter text in it. // set up WicketTester...

Xcode 4 Unit Test Bundle Target is missing

According to the documentation here, there is supposedly a target called 'Unit Test Bundle' for setting up unit tests. However in my XCode4 I cannot find such a target in the 'Add Target' dialog box. Is it a setup issue, or did I miss something? ...

What's the correct way to stub functionality for PHPUnit testing?

Hi, I'm trying to write some unit tests for a class that connects to an API. What I want to do is alter the class so that instead of actually connecting to the API, it instead loads a pre-fetched constant fixture. The method within the class that actually does the cURL request and returns the data is protected, and this is the one I wa...

Can I unit test against (build) a mock ASP.Net page structure? (code utilizing NamingContainer)

We have some basic form validation code that utilizes Control.NamingContainer. Is there anyway to create a mock page within a unit test, so the IDs and NamingContainer properties are set? ...

How would I make a thread join on another thread but only wait for n seconds of CPU time?

otherThread.join( time ) appears to wait time in real milliseconds. I want to wait time in actual CPU time so that I can get consistent behavior within my application. I've done a quick look at ThreadMXBean but that doesn't quite seem to have what I wanted ( it tells me the threads actual CPU time, but offers no convenient way to wait ...

How to unit test Database Class

This has probably been asked many times but here it goes : I have a class full of db connections open connection query db read values close connection How should I unit test this stuff? Do I need to create a fake database? I guess I could mock the MySql classes (for c#), but that's also a lot of work. Some of the statements are "I...

How to unit test this library?

I have an external library which has a method which performs a long running task on a background thread. When it's done it fires off a Completed event on the thread that kicked off the method (typically the UI thread). It looks like this: public class Foo { public delegate void CompletedEventHandler(object sender, EventArgs e); ...

Unit Testing Web Services - HttpContext

I want to write unit tests for a web service. I create my test project, reference my web project (not service reference, assembly reference), then write some code to test the web services - they work fine. However, there are some services which make sure the user is logged in to the web application by using HttpContext.Current.User.Ident...