unit-testing

Should I use Selenium for a Booking Engine?

We'll be developing a booking engine, a 4-5 step checkout process for reserving rooms with a hotel where there's a lot of complexity involved. Something similar to this. Has anyone used Selenium for something like this? What kind of tests would I be able to do? Could I set something like Selenium to go through the entire process of step...

How to write unit test to assert the value of a jQuery element

I am using jQuery 1.4.1 and here is a simple code. buildCol1: function() { var col = $('<select />', {className: 'col1' }).append($('<option />')); return $('<td />').append(col); }, I am using qunit . In this case the method call is returning a jquery element. Since I am writing a test I should have something like s = "<td><sele...

EJB3Unit testing no-tx-datasource

Hello, I am doing tests on an ejb3-project using ejb3unit http://ejb3unit.sourceforge.net/Session-Bean.html for testing. All my Services long for @PersistenceContext (UnitName=bla). I set up the ejb3unit.properties like this: ejb3unit_jndi.1.isSessionBean=true ejb3unit_jndi.1.jndiName=ejb/MyServiceBean ejb3unit_jndi.1.className=com.comp...

Django test FileField using test fixtures

I'm trying to build tests for some models that have a FileField. The model looks like this: class SolutionFile(models.Model): ''' A file from a solution. ''' solution = models.ForeignKey(Solution) file = models.FileField(upload_to=make_solution_file_path) I have encountered two problems: When saving data to a fix...

Mocking filesystem

Hi, If my unit tests rely on the file system and I need to mock this, what is the best way to go about this? Thanks ...

JsTestDriver and legacy javascript. To convert or not?

Hi all. I inherited a legacy JavaScript library simply written as a list of functions as follow: function checkSubtree(targetList, objId) { ... } function checkRootSubtree(targetList, rootLength, rootInfo, level) { ... } To test it with JsTestDriver do I have to 'clean' it to adhere to some JavaScript best practice or can I ...

Dependency Injection, Unit Testing, and Information Hiding

Suppose you have a class Foo with private member of type Bar. You don't want users to know that Foo's implementation contains a Bar and you don't want users to be able to create their own Bar and pass it through Foo's constructor, any other method, or a configuration file. Edit: Bar is also problematic in that it accesses resources ...

Testing a Singleton

I've created a singleton which in the constructor goes like this: public static class MyCertificate { private readonly static X509Certificate2 _singletonInstance = new X509Certificate2(); static MyCertificate() { if(_singletonInstance == null) _singletonInstance = GetMyCertificateFromDatabase(); } ...

Referencing fixtures from the same type in Rails

In associations between different models, one can avoid setting foreign key IDs directly by using fixture names as in this answer. What about self-referencing associations, such as when using acts_as_tree? Trying this: # categories.yml forsale: name: For Sale parent_id: nil books: name: Books parent: forsale I get this error:...

Testing an ActionResult with a Form View Model

I know this has been asked before but I can't find it so... Say I have a controller called HomeController and it has an action called Login. My Login action takes a model called LoginFormViewModel. Inside my action I can write code like; public ActionResult Login(LoginFormViewModel loginFVM) { if (ModelState.IsValid) ...

what type of testing performed on stand alone application.....?

what type of testing is performed on standalone application ,web based applicaton & client server application? ...

Hudson unable to navigate relative directories

I have a Python project building with Hudson. Most unit tests work correctly, but any tests that require writing to the file system (I have a class that uses tarfiles, for example) can't find the tmp directory I have set up for intermediate processing (my tearDown methods remove any files under the relative tmp directory). Here is my p...

Codeigniter Unit-testing models

I'm new to unit-testing, so this is maybe a little dumb question. Imagine, we have a simple model method. public function get_all_users($uid = false, $params = array()){ $users = array(); if(empty($uid) && empty($params)){return $users;} $this->db->from('users u'); if($uid){ $this->db->where('u.id',(int)$id); ...

Overwrite auto_now for unittest

I've defined some timestamps for events in the database as auto_now_add, as the information should be stored with it's timestamp the same time the event is stored. The description of the events is something like class NewEvent(models.Model): ''' Individual event ''' name = models.CharField(max_length=100) quantity =...

Ajax unit testing mocking using Jack

I am using Jack as JavaScript mocking library. http://github.com/keronsen/jack . I am also using qunit. I have following AJAX call in my javascript code which I am tring to write test for. $.ajax({ url: $('#advance_search_form').attr('action'), type: 'post', dataType: 'json', data: parameterizedData, success: functi...

How to make mock to void methods with mockito

How to make mock void methods.I performed observer pattern but i cant mock with mockito because i dont know the mock way with mockito.And i search from the internet i cant find properly sample. My class looks like public class World{ List<Listener> listeners; void addListener(Listener item) { listeners.add(item); } void doActio...

Unit Test Adapter threw exception: ... is not marked as serializable..

this error is driving me nuts: Unit Test Adapter threw exception: Type 'com.imagehawk.ZDRCreator.Config.ZDRCreatorConfigException' in assembly 'ZDRCreator, Version=1.0.5.1, Culture=neutral, PublicKeyToken=null' is not marked as serializable.. it's an exception, the only places it's used is like this throw new ZDRCreatorConfigException(...

How do I unit test a module that relies on urllib2?

I've got a piece of code that I can't figure out how to unit test! The module pulls content from external XML feeds (twitter, flickr, youtube, etc.) with urllib2. Here's some pseudo-code for it: params = (url, urlencode(data),) if data else (url,) req = Request(*params) response = urlopen(req) #check headers, content-length, etc... #par...

How do mock frameworks work?

If I was to write a mocking library, how would this work (in other words, how do "they work?)? One of the things which I wonder is that you are always setting expectations so really you need to compare the expectation to what the method does at runtime, so I assume reflection (resolving types at runtime) is required. Also, when using t...

ObjectValidator problem

Hello, I'm having problems with [ObjectValidator]. So, i have: public class UserBO { public int ID { get; set; } [NotNullValidator(MessageTemplate = "Can't be null!")] [RegexValidator(@"[a-z]|[A-Z]|[0-9]*", MessageTemplate = "Must be valid!", Ruleset = "validate_username")] [StringLengthValidato...