unit-testing

Unit Testing File I/O Methods

I am still relatively new to unit testing. I have written a class in Ruby that takes a file, searches through that file for a given Regex pattern, replaces it, then saves the changes back to the file. I want to be able to write unit tests for this method, but I don't know how I would go about doing that. Can somebody tell me how we unit ...

How to run all test-cases from several modules?

I have several modules full of test-cases and would like to create one module that runs them all. I tried loading the tests in each of the modules using TestLoader.loadTestFromModule, but it always returns empty test-suites. What is the easiest way to achieve this? ...

How to develop input object with TDD / BDD?

I have a method called ProcessPayment() that I'm developing via BDD and mspec. I need help with a new challenge. My user story says: Given a payment processing context, When payment is processed with valid payment information, Then it should return a successful gateway response code. To set up the context, I am stubbing my gateway ser...

Extending VSTS Unit Test Case generation

Here is a simple task that i want to do while running my VSTS generated UTC - In addition to printing my test result (pass/fail) in the Test Results window, I would also like to print how long the method that I'm testing took for its execution. I can use StartTime & EndTime columns to know how long my test case took to execute. However, ...

Where can I find an iPhone address book with sample data ?

I'm developing an application that get access to the iPhone address book. The simulator contains only a few sample entries. I'd like to find a sample address book with thousands of entries with various character set (English, Chinese, Arabic, etc) to fully test my app. Filling the address book myself will take for ever. Basically I need...

Verify method was called with certain linq expression (moq)

Can't figure out the syntax. //class under test public class CustomerRepository : ICustomerRepository{ public Customer Single(Expression<Func<Customer, bool>> query){ //call underlying repository } } //test var mock = new Mock<ICustomerRepository>(); mock.Object.Single(x=>x.Id == 1); //now need to verify that it was called ...

Take in console input for PHPUnit

I want to be prompted for an input when I run a PHPUnit test case and then to use that input as part of the test. In other words, I want to use a dynamic input value for a field. How can I do this? ...

Running unit tests on more than five cores in parallel

I've followed the instructions on http://blogs.msdn.com/b/vstsqualitytools/archive/2009/12/01/executing-unit-tests-in-parallel-on-a-multi-cpu-core-machine.aspx to the letter and I can execute tests in parallel. So far so good. Now the problem: I can't set the parallelTestCount to zero (Auto configure) or to a value above 5. Running fiv...

Unit testing - can't move from theory to practice

It seems like every unit test example I've encountered is incredibly obvious and canned. Things like assert that x + 3 == 8, and whatnot. I just have a hard time seeing how I'd unit test real world things, like SQL queries, or if a regEx used for form validation is actually working properly. Case in point: I'm working on two ASP.NET M...

Unit testing a JAX-WS Web Service?

Is there a way to test a JAX-WS web service? Mine is in Netbeans and I'm trying to use a web service client in the test package to do it but I wonder if this is the right way. ...

How To Write Unit Test For Method Returning JsonResult With RenderPartialViewToString?

If you look at the example at this link: http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/ How would one write a unit test for the JsonAdd method? I have a similar situation in my own code, but the RenderPartialViewToString errors when calling: ViewEngineResult viewResult = ViewEngines.Engines.FindPartial...

Book suggestion for Java web application testing

Hi. Could you recommend some books on Java web application testing? Thanks. ...

Unit testing with EF4 "Code First" and Repository

I am attempting to get a handle on Unit testing a very simple ASP.NET MVC test app I've built using the Code First approach in the latest EF4 CTP. I'm not very experience with Unit testing / mocking etc. This is my Repository class: public class WeightTrackerRepository { public WeightTrackerRepository() { _context = ne...

Some Rails unit testing questions (using Shoulda + Factory girl)

I have a couple of complicated objects to stub out (instances of gems I use). Where can I centralize these stubs to make them available to all tests? How can I programatically clear the DB between tests without rake:test? I want to quickly run individual tests through textmate, but doing so will error out since it doesn't clear the DB b...

Compact Framework: Unit tests won't hit breakpoints

Hi I'm using VS2008 and building a WinForms mobile application targetting the Compact Framework 3.5 and Pocket PC 5. I'm using the VS unit test functionality and the tests run OK but won't stop at breakpoints. I keep getting the dreaded "breakpoint will not currently be hit, no symbols have been loaded for this document" message. The so...

unit testing failing when run in batch

I am new to unit testing. I have created various tests and when I run test each one by one, all tests passing. However, when I run run on the whole as a batch, some tests failing. Why is that so? How can I correct that? ...

Firefox windows don't close after Selenium test has run

Howdy. I've been running my selenium tests using selenium rc for about 6 months and suddenly the firefox windows selenium opens do not close when the test is finished. I am using a specific firefox profile and had not updated my selenium rc jar. I thought that perhaps the latest build of firefox may have been the problem but I reverte...

unit-tests and captain obvious (ASP.NET MVC)

Hello Recently I've started to write on asp.net mvc framework. I have a problem. I can't understand meaning of the unit tests. Let's see on example public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "Welcome to ASP.NET MVC!"; return View(); } public Act...

How to know if a Java class is initialized

How is it possible to know whether a class has been initialized? Class cl = Class.forName("com.example.MyClass", false, getClass().getClassLoader()); // the false argument above indicates that the class should not be initialized // but how can I check whether it already was? cl.isInitialized(); // this does not exist, how can I know ins...

simple question how to display exception message

I have a question that may seem stupid and simple, but I hardly have any idea how to proceed with it. My question is: How can I modify the exception message and customize it such that I still have my unit testing passing? Actually I want to customize the exception message to "Student "Johny" had related files!" and as modified the API...