unit-testing

Spring: I wish to create a junit test for a web application - WebApplicationContext needed

Hi all, I am writing a junit test in order to (surprisingly) test a part of my app as a standalone. Thing is I execute the following line in a constructor being invoked in the unit test: WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); How would I go about to set up a web context when ru...

What is Mocking?

What is Mocking? ...

how to do database testing manually....... ?

Hi Guyz, I got one requriment that i need to database testing manually in backend. what are the steps should i consider while doing manuall.also let me know that how to do database testing manually ? can anybody help me ? regards kumar ...

Mock a void method which change the input value

Hi, How could I mock a void method with parameters and change the value parameters? I want to test a class (SomeClassA) which has a dependency on another class (SomeClassB). I would like to mock SomeClassB. public class SomeClassA { private SomeClassB objectB; private bool GetValue(int x, object y) { objectB.GetVa...

Method for unit testing an extension method for SqlCommand

Hi, I've created an extension method for SqlCommand that allows some additional work before executing the command: public static SqlDataReader ExecuteMyReader( this SqlCommand sqlCommand ) { // Some calculations here return sqlCommand.ExecuteReader(); } My question is what is the best way to unit test this extension method? ...

How to (unit-)test data intensive PL/SQL application

Our team is willing to unit-test a new code written under a running project extending an existing huge Oracle system. The system is written solely in PL/SQL, consists of thousands of tables, hundreds of stored procedures packages, mostly getting data from tables and/or inserting/updating other data. Our extension is not an exception. M...

Splitting a test to a set of smaller tests

I want to be able to split a big test to smaller tests so that when the smaller tests pass they imply that the big test would also pass (so there is no reason to run the original big test). I want to do this because smaller tests usually take less time, less effort and are less fragile. I would like to know if there are test design patte...

What's your approach to testing iPhone / iPad apps?

When developing for iPhone/iPad do you Do unit/integration/etc testing? What framework(s) do you use? What other framework(s) have you tried (if you decided to not use them, why not?) NOTE This is based on a question asked a few days ago (that has since been heavily edited). Question generated some interesting responses that may ...

Unit Testing UrlHelper Extension Methods

I'm trying to create unit tests to make sure my extension methods for UrlHelper work? Does anyone know how to do this? I'm using MVC 1.0 and MvcContrib. I can test the routes but can't test code like this: public static string MoreFloorplans(this UrlHelper urlHelper, long productID, int pageIndex) { return urlHelper.Acti...

PHPUnit installed but class PHPUnit_TestCase not found

Talk about falling at the first hurdle. My test script: <?php require_once('PHPUnit/Framework.php'); class TransferResponseTest extends PHPUnit_TestCase { ... } Running my test case: $ phpunit TransferResponseTest Fatal error: Class 'PHPUnit_TestCase' not found in /Volumes/Data/greg/code/syndicate/tests/TransferResponseTest...

How do I assert that a model has a readable/writable attribute?

In one of my model's I'm using some meta programming to dynamically define some methods. I'd like to test this; thus, I need a compact way to assert my model has a readable/writable attribute with a certain name. Ideas? I'm using shoulda for unit testing if it makes a difference. ...

Shoulda: How would I use an instance variable outside of a setup or should block?

I'm trying to do something like the following: @special_attributes = Model.new.methods.select # a special subset @special_attributes.each do |attribute| context "A model with #{attribute}" do setup do @model = Model.new end should "respond to it by name" do assert_respond_to @model, attribute end end end ...

How should I rewrite my code to make it amenable to unit testing?

I've been trying to get started with unit-testing while working on a little cli program. My program basically parses the command line arguments and options, and decides which function to call. Each of the functions performs some operation on a database. So, for instance, I might have a create function: def create(self, opts, args): ...

MVCContrib Testing Route with Areas

Hi, I am using MVC 2 with Area. To test routing, I am using MvcContrib. This is the testing code: [Test] public void Home() { MvcApplication.RegisterRoutes(RouteTable.Routes); "~/".ShouldMapTo(x => x.Login("Nps")); } I am not sure how to call routing definition that are stored in Areas. Calling AreaRegistration.RegisterAllAre...

Framework or tool for "distributed unit testing"?

Is there any tool or framework able to make it easier to test distributed software written in Java? My system under test is a peer-to-peer software, and I'd like to perform testing using something like PNUnit, but with Java instead of .Net. The system under test is a framework I'm developing to build P2P applications. It uses JXTA as a ...

Code generation tool, to create C# adapter classes for unit testing?

I know I wouldn't need this with Typemock, however, with something like MoQ , I need to use the adapter pattern to enable the creation of mocks via interfaces for code I don't control. For example, TcpClient is a .NET class, so I use adapter pattern to enable mocking of this object, b/c I need an interface of that class. I then produce...

C# Stress Test - Simulate multiple access to a given shared resource

How can you simulate/stress test about 100 users accessing a given shared resource (e.g. Database) in a c# unit test? ...

how to avoid returning mocks from a mocked object list

I'm trying out mock/responsibility driven design. I seem to have problems to avoid returning mocks from mocks in the case of objects that need a service to retrieve other objects. An example could be an object that checks whether the bills from last month are paid. It needs a service that retrieves a list of bills. So I need to mock tha...

Can I debug with python debugger when using py.test somehow?

I am using py.test for unit testing my python program. I wish to debug my test code with the python debugger the normal way (by which i mean pdb.set_trace() in the code) but I can't make it work. Putting pdb.set_trace() in the code doesn't work (raises IOError: reading from stdin while output is captured). I have also tried running py....

C# Visual Studio Unit Test, Mocking up a client IP address

Hey guys, I am writing some unit tests and I'm getting an exception thrown from my real code when trying to do the following: string IPaddress = HttpContext.Current.Request.UserHostName.ToString(); Is there a way to mock up an IP address without rewriting my code to accept IP address as a parameter? Thanks! ...