unit-testing

how to unit test session state

I'm trying to figure out how to unit test my object that persists itself to session state. The controller does something like... [HttpPost] public ActionResult Update(Account a) { SessionManager sm = SessionManager.FromSessionState(HttpContext.Current.Session); if ( a.equals(sm.Account) ) sm.Acco...

EasyMock andReturn() vs andStubReturn()

I'm still a rather new developer,so I might not have a grasp on all the concepts and terms which could be the reason why I don't understand this. But what exactly is the difference between using andReturn(T value) vs andStubReturn(T value) for EasyMock? Both of their parameter types are the same. In what situation would it require you d...

How to test the order of mocked calls using EasyMock

Hi, It's easy enough in EasyMock to do: EasyMock.expect(service.methodCall()); but I noticed that this does not test the order in which I execute the calls, which in a case that I am trying to test is very important. Is there anyway to do this with EasyMock? ...

unit testing time format conversions

After ncovering an ugly bug I wouldn't have caught in winter, I've started to centralize conversions between different time formats. I've already found some bugs by comparing different conversion paths, but need something more systematic. Test goals are correct conversion on all paths (of course), and errors on rimes not represented cor...

how do I repeat python unit tests on different data?

I am testing classes that parse XML and create DB objects (for a Django app). There is a separate parser/creater class for each different XML type that we read (they all create essentially the same objects). Each parser class has the same superclass so they all have the same interface. How do I define one set of tests, and provide a l...

Comparing byte[] in LINQ-to-SQL and in a unit test that uses mocking

I have the following method: User IDataContext.AuthenticateUser(string userName, string password) { byte[] hash = PasswordHasher.HashPassword(userName, password); var query = from e in mContext.GetTable<User>() where e.Email == userName && e.Password == hash select e; return query.FirstOrDefault(); } Wh...

why testing an individual junit test works, while testing them together won't?

The test that fails when tested together with mvn test (or through the ide) is called EmpiricalTest. If I test the file alone it goes through, but not otherwise. Why could that be? You can checkout the Maven source code (to test) from here. This is how I make sure the database is 'blank' before each test: abstract public class Persis...

Is there how I could programmatically ask eclipselink to drop and create all tables?

This helps in unit testing. ...

Many calls to external applications. How to test?

There is a Visual Studio plugin. The plugin uses VS SDK, few external applications and a database. A simplified version of the plugin is: Use VS SDK to get information about the current solution and its projects for i=1 to n do Call external application i (create process, add arguments, wait for result) Collect results from ap...

PLT Racket test cases for multiple values.

Hello, I can't seem to test a function I wrote in PLT Racket using the test-engine/racket-tests package. The code is listed below. It returns multiple values (not sure why they don't call them tuples). (define (euclid-ext a b) (cond [(= b 0) (values a 1 0)] [else (let-values ([(d x y) (euclid-ext b (modulo a b))]) ...

Where can I investigate junit tests in a real world project?

What is a good open source project which uses junit tests in its source code? I want to see how its doen and learn about it. ...

PEX: How would you test an equality method in pex?

So i'm here playing with PEX, it seems like a great idea. However I am having a few problems, such as I have no way to test an equals method using parameter unit tests. Maybe there is no way, maybe its a technique i haven't figured out yet. Someone must have a decent idea. If i was doing this in moq for instance, I would ensure that...

Using Javascript/jQuery is there any reason you would use YUITest over QUnit as a testing framework?

Hi i'm starting a new website and am going to be using jQuery as the library in the browser. I was looking at testing frameworks and the obvious choice for Unit Testing in jQuery is the framework jQuery itself provides which is QUnit. I have also looked a little at YUITest which looks very well documented. So my question is. If you ar...

Suggestion for UnitTest tools for C++

I am startting to develop a module using C++ and yes using VC++ 6.0. Had a look on google test framework but it supports VC 7.1 onwards. Can any body please suggest few tools for unittesting C++ exes or dlls. If the tool can be integrated to VC++ 6.0 IDE will be great. ...

Patterns for loading default data when unit testing

Looking for some strategies for how you guys are loading default data when doing unit tests. ...

How to test lambda functions with Moq?

There is a function: public class MyCacheClass : ICache { public void T GetObject<T>(Func<T> func) { T t; ... t = func(); ... return t; } } public class MyWorkClass : IWork { public Object MyWorkMethod(string value) { return new object(); } } These functions are ...

How do I Unit Test NServiceBus.Configure.WithWeb()?

I'm building a WCF service that receives requests on an external IP and translates them into messages that are sent via NServiceBus. One of my unit tests invokes Global.Application_Start(), which performs the configuration of the application, and then attempts to resolve the web service to validate that the container can build up all of...

Testing android project with db4o (or other referenced lib)

Hi, I'm working on a project for android that uses an external library, db4o. Well, I've created a test project and I was trying to test my PersistenceManager, an object that controls the database life-cycle and exposes part of the ObjectContainer api (ObjectContainer is an object from db4o library). When I started to write the tests, I...

Best practice: Ruby/Rails Rspec regex testing

Could you tell me how to test regex-code correctly? I test my user-login attribute with following code: # user.rb class User < ActiveRecord::Base #... validates_format_of :login, :with => /^[a-zA-z0-9_.]{3,18}$/ end # user_spec.rb describe User do before(:each) do @user = Factory.build(:user) @user.save end subject...

Grails - How to Unit Test addTo*

Is it possible to unit test addTo* functions in Grails ? thanks for your help. ...