unit-testing

Any way to automate - for testing - a human-dependant action?

I wonder if there are any good / possible ways to automate - for a unit test perhaps - a human-dependant action on an eCommerce website? For example, could I have a macro or a script to simulate "can user put items in basket?" or "can user reach the payment gateway?". I am currently managing a very heavily used eCommerce codebase and w...

MOQ - how to mock an interface that needs to be cast to another interface?

what I want to do is construct a moq for I1 - which is fine ... however in the course of the method that I am testing that uses this mock I need to cast it to I2 in order to access some properties that are not on I1 Interface I1 { int AProperty{get;set;}} Interface I2 {int AnotherProperty{get;set;}} I then have some objects Class O...

PHPUnit: continue after die, expect "die" or somehow handle die() ?

Hi all. I'm writing some unit tests. The system I'm currently testing is a web-app in an MVC framework. If we want to render pages without the site-skin system we've traditionally run our code as usual, but printed a "die();" statement at the end of the function to exit before the rest of the website renders. Well now that we're addi...

Self-contained test library project cannot find the library classes

According to this SDK guide, unit-testing a Library project can be achieved by creating a standard application project, reference the Library project and then instrument the application for unit testing. However, when I do this and launch the test application I get the message No tests found with test runner 'JUnit 3'. I'm using E...

Test coverage tools for MS Test

I have a project in VS 2008 and written a MS Test cases for that. I am looking any open source Test Coverage tools which are free (Like NCover) to perform Test Case coverage tools in .net Pleaes let me know if any one useed any tool which is open source and free ...

What are some c# projects to look at for good implementation of unit tests?

Not something too large, yet no 2+2=4 type of examples either. Specifically it would be nice if it were WPF and MVVM. I'm confused on what to test for the view model. How do you test what is in Lambda's? Do you? Do you make a function public just so you can test it. Or do you just test the final result? ...

MSTest, Accessors, Inheritance, and Private Members

I'm trying to write some tests for an MVC application we're developing. We have a BaseController class that contains the following: public class BaseController : Controller { protected string UserRole { get; private set; } We then have a controller that inherits from the BaseController: public class CustomFieldController : BaseCo...

Execute setup() once workaround causing TestSuit to fail

I have 2 files: xxxxxTest.java [refer this] public class xxxxxTest extends TestCase { // Run setup only once public static Test suite() { TestSetup setup = new TestSetup(new TestSuite(xxxxxTest.class)) { protected void setUp() throws Exception { //Some init which i need only once }...

Methods and recommendations for testing persistence of entities

Everyone loves unit testing. But testing persistence of entities is a bit different. You are testing a process occurring across multiple layers using different languages. Your tests have side effects (in the sense that rows are being added / modified etc). I would like to know how you do this. For example, do your tests create a whole n...

Mocking Enterprise Lib 5 'Database'

Is it possible to mock the enterprise library 5 version of 'Database'? If so... how? There is no IDatabase interface (which is a mystery as I though Microsoft P&P would be more on the ball about testability benefits of exposing such an interface). I have a Repository class which used EntLib 5 Data Access Application Block. I am retro ...

Waiting for all threads spawned by my code under test in JUnit test case

How do I ensure in a JUnit test case, that all the the threads spawned directly/indirectly by the method under test are done with there job, so that I can assert the final result? @Test public void testMethod() { Result result=method();// may spawn multiple threads to set result.value Assert.assertTrue(result.getValue()==4); //shoul...

Is there a multi-process unit testing framework / junit addon?

Imagine two servers (each within an own jvm process) which communicate using some form of messages (e.g. simple producer/consumer) I'd like to write unit tests that will test the behaviour of these two servers. My questions are: Are there some frameworks (or a junit addon) for this problem? I'd like to run a junit test class (or even ...

Fixture.CreateAnonymous method kills test runner process with an error (AutoFixture) when using AutoMoq to create a Controller

I'm trying to use the AutoMoqCustomization with AutoFixture to create an ASP.NET MVC2 Controller in a unit test via the Fixture.CreateAnonymous method. I've tried in both xUnit under TestDriven.NET, the xUnit test GUI and in MSTest and all have the same result: a massive failure of the process running the test. On Windows 7 x64 if that...

Behavior vs. State Based Testing

I know this question is part of a bit of a religious war, but I have the following situation: I have an object, Responder that calls a method on object Updaterin response to different events. I recently separated the testing in this way: state-based tests for the Updater method itself, and behavior-based tests for the Responder that cal...

Convenient method in GoogleTest for a double comparison of not equal?

I'm looking for something similar to the ASSERT_EQ / ASSERT_NE for ASSERT_DOUBLE_EQ. Maybe I'm missing an easy way of doing this without having a ASSERT_DOUBLE_NE? ...

Unit testing named pipes

What is the recommended way to unit test an object that publishes via NamedPipeServerStreams? My thought was to use a NamedPipeClientStream in the unit test but the test just ends up hanging; I suspect this is due to both of them being in the same process. ...

testng from ant: specify -server -Xms ?

I'm running testng from ant using the task. I'd really like to add the -server option to the forked jvm as well as specifying the amount of heap space. Anyone know how to do it? I don't see anything here: http://testng.org/doc/ant.html Thanks, Ben ...

drop into an interactive session to examine a failed unit test

I'd like to be able to enter an interactive session, preferably with IPython, if a unit test fails. Is there an easy way to do this? edit: by "interactive session" I mean a full Python REPL rather than a pdb shell. edit edit: As a further explanation: I'd like to be able to start an interactive session that has access to the context i...

How can I clear the database (domains) between easyb scenarios in Grails Integration Testing?

I am running an Integration Test for a Grails application. I am using the easyb plugin. The problem is that the database doesn't seem to get cleared out between Scenarios. My When I run standard Grails Integration Tests, the persistence context is cleared between each test. The easyb Stories are in the Integration folder, but the Gr...

Howto write unittests for struts 2 annotated based validation?

Hi! I am using annotation based validation in Struts 2.1.8.1. Now i want to write a unit-test using jUnit 4 for them but have not got a clue how to do it. I found several links which worked in Struts 2.1.6 but not in Struts 2.1.8.1 anymore: http://bloodredsun.blog.com/2009/10/21/unit-testing-struts2-actions-with-annotation-based-valid...