unit

Problems unit testing setInterval function in Javascript

Hi all: I am having difficulties testing window.setInterval function in my Javascript file. Below is the scenario... basically I have a setInterval function in a function which I want to test: var dummy = false; // global variable not set anywhere else var INTERVAL_TIME = 20; // global variable not set anywhere else function myFunctio...

How to verify a certain javascript function has been called during unit testing

Hi all: I'm using JsTestDriver and a bit of Jack (only when needed). Does anyone know how to verify that a javascript function has been called during unit testing? E.g. function MainFunction() { var someElement = ''; // or = some other type anotherFunction(someElement); } And in the test code: Test.prototype.test_mainFunct...

Unit testing jQuery document.ready function

Hi all: I have a question in regards to unit testing jQuery's document.ready function(). Currently I have 2 scenarios in my code: function myFunction() { $(document).ready(function() { ... }); } And: $(document).ready(function() { // some really long setup code here }); I tried to write a unit test for the first scenario,...

VS2008 Unit Test Project bugs...

Hi, I'm using VS 2008 Developer Edition and am finding some bugs with the Test Projects. I am getting one error that doesn't make sense - I have a class called 'Foo' which I need to test and created the blank test class automatically. Foo takes 3 paremeters in its constructor - IBar, IBaz, IBang. When I write a test case, I will Dim ...

How do I stop the Development Server starting during Unit Testing?

I have a Visual Studio 2008 solution that contains around 30 projects. Some of these are web services / WCF services / ASP.NET MVC applications. When I run all unit tests (Ctr+R, A) it insists on spinning up all the Development Servers for these various projects. This means that it takes far too long to run the tests and, actually, none...

Void in constrast with Unit

I would like to understand which is the difference between these two programming concepts. The first represents the absence of data type and at the latter the type exists but there is no information. Additionally, I recognize that Unit comes from functional programming theoretical foundation but I still cannot understand what is the usab...

Uses with unit file path in unit file

Hello. I have problem. I ll try to explain it. I have a unit which has a class and may will have new functions. D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas 8DC8977E7A7B469AACFE3CC77CA7075E\UnitFile1.pas Both of them have same class: IClass_1 = class Im using code numbers for different versions of this file. Another unit file (Uni...

ASP.NET MVC tests with MSpec. Is this correct or needs refactoring ?

Hello, I'm new to MSpec and would like to know if the way I wrote my test for ASP.NET MVC is correct. The test passes but I don't really like the way it's written and it seems awkward. I'm certainly missing something. public class AccountControllerTests3 { protected static AccountController controller; static IFormsAuthenticati...

Zend Framework: How should I unit test my Mapper in Zend_Db?

Hello, How would I test my mappers in Zend_Db? Each of my model will have 3 classes: The Model The Mapper The DbTable Here is my Unit Test: <?php // Call Model_BugTest::main() if this source file is executed directly. if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "Model_ArtistTest::main"); } require_once...

unit test with mock objects

Please take a look at the following article about testing with mocks So there is an example of unit test with mock objects. As you can see, the test is written for GetPersonByID method. In the IPersonServices interface there is another method: List<Person> GetPersons(); Can anyone tell me how a Test method on this service should look ...

RegexValidator does not work for char?

Hello, Why the following test does not fail? [TestMethod()] public void tip_cicluTest() { MyBO target = new MyBO() { tip_ciclu = 'S' }; char expected = 'S'; char actual = target.tip_ciclu; Assert.AreEqual(expected, actual); ValidationResults vr = Validation.Validate<MyBO>(target,"vali...

Why NotNullValidator does not work?

Hello, I'm using Microsoft Enterprise Validation. But in this case the test passes, even if i assign null value to that attribute. Why? [NotNullValidator(MessageTemplate = "Cannot be null!", Ruleset="validate_x")] [StringLengthValidator(10, RangeBoundaryType.Inclusive, 40, RangeBoundaryType.Inclusive, Ruleset="validate_x")] ...

"Normal" ratio of codebase vs. test assert problems when a test fails?

I'm currently working on a project with some fairly significant business rules where the problem space is being 'discovered' as we are writing the solution (pretty typical chaotic project management kind of thing). We have decent test coverage & rely on them quite a bit to make sure our signficant changes don't blow anything up. This sce...

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...

Rhino Mocks overwriting stubs possible?

I have this problem, which may be a bug in Rhino Mocks 3.5: stubObj = MockRepository.GenerateStub(IObject); stubObj.Stub(a=>a.Get()).Return (Guid.Empty); //1.stub stubObj.Stub(a=>a.Get()).Return (Guid.NewGuid()); //2.stub, should overwrite the first one? this: var value = stubObj.Get(); returns Guid.Empty, is this the correct beh...

Using mocking during testing does it worth the effort?

During this semester my professor tried to convince us why is good to use unit tests during development, why is it good to validate data(Microsoft Application Block) and also he told us about using mocking(RhinoMocks) in order to test our methods when we didn't had access to a database. I had to do some unit tests with mocking and in or...

Can a Mock framework do this for me ?

Hello, I am a bit confused from wiki: "This means that a true mock... performing tests on the data passed into the method calls as arguments." I never used unit testing or mock framework. I thought unit tests are for automated tests so what are mock tests for? What I want is a object replacing my database I might use later but still ...

unit testing sync framework

Hi all, We have built a custom provider for the microsoft sync framework, how would you go about unit testing it or would you not bother with the unit testing and focus on integration tests? Cheers alex ...

Trying to run Android JUnit tests in Ecclipse fails!

I have seen all the examples on the web and it seems real simple. I have a bare-bones app that displays a string. I have a a Android JUnit test project that I created when the app was being created (ecclipse asked if I wanted to create a test app). When I run the test app (Run As --- Android JUnit) I see the foolowing in the console.......

consume/unit test forms validated restful webservice

Hi, I am using asp.net mvc to create forms validated restful webservices. I am just wondering whether it is possible to consume these web services via, for example, a console application? How do I create the cookie etc. Ultimately I would like to unit test the actual web services. Thanks a lot. christian ...