unit-testing

How to assert that a jQuery cluetip has been binded to something?

Hi all: In my code, there is a cluetip that binds itself to an anchor. I need to know what sort of properties can I assert when unit testing it? At the moment, all I could do is to assert the id of the cluetip, which seems insufficient. I want to find out whether there is some sort of class in cluetip that changes when it is binded t...

Generic unittest for rule-conform implementations of common .net interfaces and overloads?

The caption may sound a little weird. Allow me to elaborate using an example. The Object.Equals function usually requires that a.Equals(a) returns true. Unless you're doing something twisted in your code, every class should adhere to this rule. So we could write a generic unittest that checks all available classes to comply. (We might ...

Should code coverage be used as a "Milestone" that can block a project's progression?

I am a development manager on a project with a painfully low unit test code coverage and we are definately feeling the weight of the "techincal debt" in the legacy code in our system. My question is if anyone uses code coverage as a milestone or development threshold that prevents the project from moving to the next sprint until the cod...

Automated profiling of unit tests from TeamCity?

Is there any way to do automated profiling of unit tests when we run them via TeamCity? The reason I'm asking is that while we should, and most of the time do, have focus on not creating performance-wise bad code, sometimes code slips through that seems to be OK, and indeed works correctly, but the routine is used multiple places and in...

how would I unit test this nhibernate query?

public Category GetByName(string name) { Category category = Session.CreateCriteria(typeof (Category)) .Add(Expression.Eq("Name", name)) .UniqueResult<Category>(); return category; } Or is it so clear that it doesn't need testing? ...

How do I unit test routes for web forms?

I have a web form such as mysite.com/list.aspx?state=florida&city=miami that I want users to browse using mysite.com/florida/miami/ and I'm using routing to do so. Then instead of using query string parameters, I end up having to use HttpContext.Current.Items[key] to retrieve the values on my list.aspx page. I have included the code be...

How do I write unit tests for ensuring numerical accuracy in scientific computation in C?

I'm currently exploring interfacing C and R (using R's .Call for speed). I've only used C for trivial integer computation and text processing applications, and I've never had to worry about issues with float variables, underflow, etc. What tests can I write for functions to ensure numerical accuracy? ...

Unit testing stripes validation annotations directly

Stripes allows you to validate your form input values using the @Validate annotation on your member variables. Does anyone have any experience testing these annotations directly. I could do this by testing the validation errors that come back from the ActionBean, but this seems a little long winded and I would like a more direct method o...

Unit testing with Oracle

Does anyone have any frameworks/apps/methodologies for creating Unit tests with Oracle?. I'm using Oracle 11g. I also have Team Foundation Server installed, where we do all our other development work with Visual Studio on a web app. Edit: I'm looking to run unit tests on Packages, Procedures and Functions within Oracle (PL/SQL) ...

Keep getting gcov error when trying to run lcov in Windows command line

Hi all: I was wondering what else is actually needed in order to run lcov in windows command line? Every time when I run perl lcov, I always get a reminder or errors similar to the following: geninfo: ERROR: need tool gcov! I looked into my bin directory, and couldn't find a gcov.exe. I normally do perl genhtml filename to get a ht...

Testing the internals of a method with RhinoMock or Moq

Quite new to this mocking thing, I have a couple of questions. Correct me if I'm wrong: Mocking does not initialize the real method i.e. Mocking will not actually call the constructor of your class. Instead it does something like look at the signature of the class and create an object with that signature but with none of the methods fun...

Mocking - setting a property before calling the constructor

In RhinoMocks or Moq, can properties on an object be set before the constructor is called? I'm trying to test a method. The class containing the method has some code in it's constructor which depends on some members being set, unfortunately there's no params in the constructor to set them so I must set them through a property. Is ther...

Testing subpackage modules in Python 3

I have been experimenting with various uses of hierarchies like this and the differences between absolute and relative imports, and can't figure out how to do routine things with the package, subpackages, and modules without simply putting everything on sys.path. I have a two-level package hierarchy: MyApp __init__.py ...

Have ruby Unit::Test speak the results of the test

I've been using the built-in OSX 'say' command to signal the end of long running tests. It's easy and convenient. I'd like to make it speak the last line of the results which says "6 tests, 18 assertions, 0 failures, 0 errors" but still keep the ongoing output. Any ideas how to do this? I've tried: ruby overlay_test.rb | tail -n 1 | ...

my class has 30 properties, unit testing is a pain no?

My class has like 30-40 properties, and I really want to unit test. But I have to create a moq instance (many of them, with different combinations etc). Is there an easy way? This is real work! My class can't be refactored, "trust me" (hehe, no really it can't, they are just properties of the object that are very tightly coupled). ...

is it possible to ignore a fatal error in PHP?

I understand the significance of the term 'fatal error', but I want to write a test class like this (disgustingly simplified): class tester { function execute() { if( @$this->tryit() === true ) return true; return false; } function tryit() { $doesntexist = new noobject(); return true; } } act...

Using Groovy MetaClass to overwrite Methods

I have a POJO that uses a service to do something: public class PlainOldJavaObject { private IService service; public String publicMethod(String x) { return doCallService(x); } public String doCallService(String x) { if(service == null) { throw new RuntimeException("Service must not be null...

NUnit Unit Test has "ExpectedException" but still failing on exception

I have a unit test that is failing because a System.ArgumentException is being thrown, even though I am expecting it and it's deliberate behaviour - what have I missed? [Test] [ExpectedException(typeof(ArgumentException), ExpectedMessage = "Seconds from midnight cannot be more than 86400 in 010100712386401000000012")] public void TestPa...

Run mbunit 3.1 tests in resharper 4.5

I have earlier used mbunit 2 and with this plugin I could get my tests to run in the resharper test dialog. Now with mbunit 3.1, I read that I didn't need any external plugin. So I donwloaded Gallio and got the new MbUnit.dll. Added a reference to it in my test-project. Now it looks correct in visual studio. I've got the green/yellow c...

How can we decide which testing method can be used?

i have project in .net , i want to test it. But i dont know anything about testing and its method. how can i go ahead with testing. which method is better for me for begining? Is there anything to decide which testing method is taken into account for better result? ...