unit-testing

Integration testing private classes and methods

For unit testing you shouldn't test private methods, yes, but for integration tests (using a unit testing framework like MSTest or NUnit) I would very much like to run the internal API calls against a test url, to make sure the current code works when the third party API vendor changes their backend. Given the complexity of the system (...

How do I allow an implementation to call a Mock (Moq) method with its own arguments?

When testing a class that uses a Moq dependency, I'd like the class to supply the arguments to a Moq method, rather than creating the arguments myself in the test case. I have an interface, that has one method, which takes one argument. public interface IMessageForwardProxy { IMessage Send(IMessage request); } I have a class that...

How do you get the python Google App Engine development server (dev_server.py) running for unit test in GWT?

So, I have a GWT client, which interacts with a Python Google App Engine server. The client makes request to server resources, the server responds in JSON. It is simple, no RPC or anything like that. I am using Eclipse to develop my GWT code. I have GWTTestCase test that I would like to run. Unfortunately, I have no idea how to actuall...

How to report the effect of TDD

I am trying to become more familiar with test driven approaches. But I am embarrassed because I have to report the effect of TDD. I should report on the UT result to the superior. (I reported value of bugs, when I enforced UT(unit test).) But I can not obtain the UT(unit test) result if I try TDD. Please let me know how to report the e...

Creating a JUnit testsuite with multiple instances of a Parameterized test

I want to create a TestSuite from multiple text files. Each textfile should be one Test and contains the parameters for that test. I have created a Test like: @RunWith(Parameterized.class) public class SimpleTest { private static String testId = "TestCase 1"; private final String parameter; @BeforeClass public static void befor...

DbUnit: problem with increment id generation

I am using DbUnit together with Unitils, which works great most of the time. Today I found a strange problem. Situation is: I use Hibernate, and have id with "increment" generator: <id name="Id"> <generator class="increment"/> </id> I prepare test dataset, where maximal id is 5. I use clean-insert loading strategy. I ha...

Mocking method call with out param and no return value in Rhino Mocks

So I've got this method called LoginUser: public void LoginUser(out SystemUser userToLogin, string username) Having just started with Rhino Mocks, I'm having a little trouble mocking a call and return value from this method while testing my Presenter code. What's the correct syntax in this instance? ...

Flex Unit - testing a library wrapping remote objects

I'm wrapping RemoteObject inside a class for easier managing of retries, timeouts, failures and such non standard scenarios. So when wrapping a RemoteObject inside another class, how would I go about unit testing this? Here is an example of how to use the class: // set up the object as you would a RemoteObject, but without events: var...

Unit Testing or Functional Testing?

I have recently heard of Functional Testing over Unit Testing. I understand that Unit Testing tests each of the possibilities of a given piece of code from its most atomic form. But what about Functional Testing? This sounds to me like only testing if the code works, but is it as reliable as Unit Testing? I've been told there was two ...

Javascript Sandbox unit testing

I am using QUnit, which is excellent. I have enclosed my JS app in the (function () {})(); sandbox. This hides a lot of code that I don't want public, but I also need to test that code. Here is an example of how this works: (function () { var PublicAPI = window.PublicAPI = {}; PublicAPI.publicFunction = function (fo...

Passing Object Parameters for TestNG methods?

Here is my situation. Before my tests are run, in the beforesuite, I instantiate a bunch of "environment objects" These objects get created based on my environment configuration file. It is my tests that will actually be using these environment objects. The problem is how can I pass them to the tests. Your first impulse might be to ...

Can Pex (more specifically Moles) be used to create a sealed class?

I am trying to mock my Linq To SQL classes. I have the following code: IQueryable<User> vUser = (from aUser in _ctx.Users where aUser.UserName == userName select aUser); Clearly while doing a unit test _ctx.Users is null. I can mock _ctx (the data context), but Users is a Table<T> and is sealed. So this fails: _c...

How much unit-testing before start coding a method/class?

I´m starting (trying at least) to do coding using TDD principles and I have this question: how much tests do I need to write before actually start coding? Take for example a hypothetically Math class and a method Divide(int a, int b). a) Do I have to fully test all methods of Math class (Sum, Average, ...) before start coding Math? b)...

iPhone unit test linking problem, can’t find DevToolsBundleInjection.framework

I'm trying to setup application unit tests for my iphone app. So I made a copy of the app target, and a unit test bundle target as described in apple's documentation. After following Apple's directions, I wasn't able to reference my classes in the unit tests, so I linked the app into the unit test bundle using the "Bundle Loader" build ...

How to run Junit testcases from command line?

I would like to run junit test cases from commandline. Im using eclipse ...

simpleJdbcTemplate. - insert and retrieve ID

I'm putting the data into database with simpleJdbcTemplate. simpleJdbcTemplate.update("insert into TABLE values(default)"); I dont want to put any data because i dont need it for my unit test purpose. How can i get the id from the inserted row? I can retriev the current sequence value but if somebody else will do a insert then i will...

Are there any visual tools for Python unit tests?

I'm writing quite a few unit tests and using nosetests to run them. Nose certainly makes it nice and easy to run tests, but the output can be pretty cluttered at the best of times, and a downright mess at others, depending on warnings and errors. I was wondering if there are any visual tools that wrap nose so that the feedback cleaner....

How to make sure that CreateChildControls() method is called when unit testing custom ASP.NET web controls?

Hi, I want to unit test my rendering engine for an ASP.NET app. I have some custom controls created in that app. Most of those control rely on having CreateChildControls() method called by the ASP.Net engine wheather during initial call or a postback. When running a test CreateChildControls() does not get called and the control is in an...

database setup for Unit testing Linq to Sql, where database have relationships

I google around unit testing LINQ to SQL and people are using MockDatabase class where we have list and add data to those Lists. This will fit in the scenarios where we dont have relationships. I am behind using some data or mdf file in the unit test project which will have the same structure as like my actual database with all relation...

unit testing IDataErrorInfo with tryupdatemodel in MVC

Hi, I'm trying to unit test a controller action in which I call tryupdatemodel, but the validation does not fire. When I run my application the validation occurs and is fine. My guess is the the model binder is not loaded in test scenarios, how can I test my action ? here is the code Company object public partial class Company : ID...