unit-testing

TDD - top level function has too many mocks. Should I even bother testing it?

Hello, I have a .NET application with a web front-end, WCF windows service back-end. The application is fairly simple - it takes some user input, sending it to the service. The service does this - takes the input (excel spreadsheet), extracts the data items, checks SQL db to make sure the items are not already existing - if they do not ...

using Moq and NUnit , what is write approach / better syntax ?

I am trying to test this behavior -- BLOGTableAdapter.GetBlogsByTitle(string title) is called and for once only -- and is called with string having length greater than 1, -- and it returns BLOGDataTable Object [Test] public void GetBlogsByBlogTitleTest4() { var mockAdapter = new Mock<BLOGTableAdapter>(); ...

Enumerate Open JDBC Connections?

How do I enumerate/count all open JDBC connections? I've seen this thread, which doesn't answer my question. My interest is in writing test code in which the object being tested (call it ConnectionUser) maintains its own connection. In my tests, I want to do things like verify that instantiating ConnectionUser doesn't open a connection,...

How to mock System.DirectoryServices.SearchResult?

If you have a method that needs to be tested that takes a list of SearchResults public virtual void ProcessResults(IList<SearchResult> list) { //Code to tests here } How do you mock up that list of SearchResult? Note: No low-level injection frameworks (eg TypeMock) allowed. ...

Running JavaScript unit tests headlessly in a Continuous Integration build

I have a webapp build plan running on a Continuous Integration system (Atlassian Bamboo 2.5). I need to incorporate QUnit-based JavaScript unit tests into the build plan so that on each build, the Javascript tests would be run and Bamboo would interpret the test results. Preferably I would like to be able to make the build process "stan...

How to get the Model from an ActionResult ?

I'm writing a unit test and I call an action method like this var result = controller.Action(123); result is ActionResult and I need to get the model somehow, anybody knows how to do this ? ...

How to execute sql-script file using hibernate?

I gonna write several intergration tests which will test interatcion with db. For each test I need to have a certain snapshot of db. Each db snapshot saved in .sql file. What I want is to execute certain script file in certain test method, like this: @Test public void test_stuff(){ executeScript(finame.sql); ... testing logic ......

Rails controller testing - Validation errors do not raise a HTTP error response

I have an ActionController derived Test which sends a 'post' request to the controller under test with incorrect data. The controller tries to create a new object and save it. The model has validation methods that get triggered on save and they generate a validation error detecting the incorrect data sent by test. So far so good. Now, c...

Rails strange error => IndexError: string not matched

Hi everybody, I've got a very strange message error. I think it's not coming from Ruby but from the unix system. So, I have the following test file: require File.dirname(__FILE__) + '/../test_helper' class CatTest < ActiveSupport::TestCase def test_truth assert true end end So, nothing coming from YAML files in the Fixt...

MS Test error when running all tests

I am currently working on a project that is using MS Test for unit testing. When I do a "Run All Tests" I get the following error for about 1/3 of the tests: Test method [Test Method] threw exception System.IO.FileLoadException, but exception System.InvalidOperationException was expected. Exception message: System.IO.FileLoadException...

NUnit: configuration settings cannot be found

I've written an NUnit test project against an ASP.Net project. The code being tested cannot find the configuration values (in Web.config) when invoked from my test project. What is the right way to provide these configuration settings so my tests will run? ...

How to speedup python unittest on muticore machines?

I'm using python unittest in order to test some other external application but it takes too much time to run the test one by one. I would like to know how can I speedup this process by using the power of multi-cores. Can I tweak unittest to execute tests in parallel? How? This question is not able python GIL limitation because in fact...

Which open-source C++ projects have good (inspiring) tests?

What are inspiring examples of open-source software written in C++ with great tests? I would like to read, study and follow. ...

How to mock an object, declared / initialized inside a method under test ?

Consider this programs public class ItemManager { private ItemFetcher itemFetcher; public ItemManager(ItemFetcher _itemFetcher) { itemFetcher = _itemFetcher; } public List<Item> GetItemsFomTable() { List<Item> itemsList = new List<Item>(); Item item; DataTable resultDataTable = it...

Unit testing large blocks of code (mappings, translation, etc)

We unit test most of our business logic, but are stuck on how best to test some of our large service tasks and import/export routines. For example, consider the export of payroll data from one system to a 3rd party system. To export the data in the format the company needs, we need to hit ~40 tables, which creates a nightmare situation...

are there any good unit testing packages for excel

are there any good frameworks that can help unit test code in excel ? ...

How to automate unit testing in Squeak

I am checking Squeak homework assignments submitted by my students. I have written an SUnit test case with a bunch of tests and now I want to run these on all submissions. I would like to somehow automate - whether from inside Squeak or with shell scripts - the process of loading a student submission, running the test case on it, and sa...

How to model a templating class

Hi all, I am writing a basic templating class for my own project. The basic usage is this: $template = new Template('template_file.php'); $template->assignVariable('pageTitle', 'Home page'); $template->render(); Contents of 'template_file.php': <?php print $pageTitle; ?> This is what template class does step by step: Stores vari...

Approaching refactoring

I have a very data-centric application, written in Python / PyQt. I'm planning to do some refactoring to really separate the UI from the core, mainly because there aren't any real tests in place yet, and that clearly has to change. There is some separation already, and I think I've done quite a few things the right way, but it's far fro...

Where and how can I learn software testing techniques?

I want to learn how to build “robust” software that is designed to test itself. In other words, how do I implement automated tests in my software ( using java or groovy or c++ ). So I want to know where to learn this (books or websites) and which tools and libraries I will need for this? ...