unit-testing

Programmatically getting the "Z" position of a UIView compared to it's siblings

My class has logic for inserting views in certain levels in the hierarchy. containerView = [[UIView alloc] init]; shadowView = [[UIView alloc] init]; contentView = [[UIView alloc init]; [containerView addSubview:shadowView]; [containerView insertSubview:contentView belowSubview:shadowView]; Later down the line, it flips them so the sh...

QGraphicsSceneEvent unit testing?

What's the recommended way to do unit testing of events for classes derived from QGraphicsWidgets? Is there an equivalent to QTestEventList for QGraphicsSceneEvents? We need to simulate mouse events in QGraphicsWidgets. Thanks, Alex ...

Unit tests: finding class dependencies

Are there any automated tools to find class dependencies when writing unit tests. An example to show what I mean: We want to write unit tests for class ToBeTested. So I will write some tests to verify the expected behaviour of the class. Now I still dont know if there are class depencies as in ToBeTested probably uses lots of other cla...

Unit Testing in .Net with Endeca Objects

Most or all of Endeca's objects have internal constructors. I'm working on a good project that lacks great test coverage around the Endeca API, are there any good strategies to unit testing the interactions with Endeca? So far the best we have is kind of a poor man's adapter pattern: public class DimValue : IDimValue { public DimVa...

C++ unit testing with VS test professional.

Does any one know if I can test native code in VS Test 2010? ...

Why is it hard to unit test singletons?

I've read cases for and against using the singleton pattern. One common case against describes the difficulties in unit testing with singletons, but I'm unclear as to why this is? If the unit test is part of the build couldn't you just reference the singleton and use it when its needed? (I'm thinking from a java perspective but I guess...

Testing in Python - how to use assertRaises in testing using unittest?

Hi, I am trying to do a simple test in Python using unittest, to see if a class throws an exception if it gets an unsuitable input for the constructor. The class looks like this: class SummaryFormula: def __init__( self, summaryFormula): self.atoms = {} for atom in re.finditer( "([A-Z][a-z]{0,2})(\d*)", summaryForm...

Silverlight in browser UnitTesting Mock<FileInfo>

Hi All, I'm facing difficulties in Silverlight (inbrowser) UnitTesting using Mock to read a file into my ViewModel. It gives me an AccessDenied error message. Is there another alternative method for that kind of problem? My UnitTesting is DragAndDrop Image file in Silverlight 4. eg: unittesing.cs var fileInfo = new Mock(); ...

Calling controller from junit test

Hi How can I call a spring annotated controller from a JUnit test, in a way so that spring comes into play with binding and all, but without making a http request (just mocking out the request object)? It has to include the whole shebang from the controller and down, with JPA and database and all. We are also using EJB, so maybe a bean ...

Visual Studio data-driven tests

Hi, I'm using a TextContext property to access the current row in an Excel file. The test is repeated for all rows. Is it possible to access all rows in a single step? Rows are related, hence for me one sheet should be a complete run. Edit: I add some code as requested: int result = this.TextContext.Rows[0]["GlobalResult"]; foreach(va...

Gallio: Cannot run tests because the MSTest executable was not found

I installed the newest Gallio release 3.2.603 on a box without Visual Studio that will be our CI server. The NAnt script successfully built the .Net 4.0 projects but when it tries to run MSTest tests the following error occurs. [gallio] Gallio NAnt Task - Version 3.2 build 601 [gallio] [error] Assembly XXXXXXXXXXXXXX [gallio] Cannot r...

Classification of Unit Testing

Assume I have built a MVC web apps written using Java. Now I want to write unit tests for the web apps, what kind of unit testings should be done for a normal mvc web apps? model testing controller testing ui testing db testing any more? ...

Verify that a base protected method is called with Moq 3.1

I have a class that inherits from an abstract base class. I am trying to verify that a specified protected method in the base class is called twice and I'd like to verify that the parameters passed are specific values (different for each call). I was hoping that I'd be able to use Protected with either Expect or Verify, but seemingly I'...

Visual Studio 2010: Unit test results with "jump to file at line/col" links

I'm unit testing a compiler and would like to provide a unit test result that can be clicked and will bring visual studio to a specified test input file with the cursor at a specified line/col. Is this possible? I've tried the format outlined at http://blogs.msdn.com/b/msbuild/archive/2006/11/03/msbuild-visual-studio-aware-error-message...

Test framework allowing tests to depend on other tests

I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests. This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass. The point of such a setup would be to allow the root cause to be more r...

C# unitesting method with MySql query

Hi all, I've made an attempt to unit test a methods in the database layer of my app. In my test I was planning to write mocks to avoid having a live connection to MySQL. I'll write down a simplified version of my code to illustrate. Let's start with the unit test: [TestMethod()] public void TestMethod1() { DataBaseInterface database ...

Microsoft.Web.Mvc.LinkBuilder.BuildUrlFromExpression failing when testing Asp.net MVC app

So I'm trying to unit-test a controller method. I'm using MSTest in VS 2010, and Moq 3.1 Test method: [TestMethod] public void TestAccountSignup() { var request = new Mock<HttpRequestBase>(); var context = new Mock<HttpContextBase>(); AccountController controller = new AccountController(); ...

White-box testing - friends or preprocessor?

So, imagine we have a class like this class Testee { public: void Func() private: void auxFunc() }; and we want to do white-box unit-testing on it. Which do you think is a better approach? To declare the tester class a friend of the testee class? Or use the preprocessor like this: class Testee { public: void Fu...

How can I distinguish between "run all tests" and "run just this test"?

I have tests which run very slow, say a test which exports a large database to test the exporting code for memory leaks. I'd like to have these tests in my usual test suite but they should be ignored unless one of these conditions is fulfilled: The test is running on a CI server The user has selected this test in the IDE and runs it ...

I'm trying to mock Jersey WebResource with Mockito, and can't do it...

This is my code (Jersey 1.4 + Mockito 1.8.5): import org.junit.Test; import static org.junit.Assert.*; import com.sun.jersey.api.client.WebResource; import static org.mockito.Mockito.*; public FooTest { @Test public shouldMakeAHttpCall() { WebResource wr = mock(WebResource.class); doReturn(wr).when(wr).accept(anyVararg()); ...