I must be missing something. I'm trying to stub methods on a class in PHPUnit, but when I invoke the method on the mock object, it tells me that method is undefined.
Example class to stub:
namespace MyApp;
class MyStubClass
{
public function mrMethod()
{
// doing stuff
}
}
To stub it, I write:
// specifying all ge...
I've recently started to learn Fluent NH, and I'm having some trouble with this test method. It takes forever to run (it's been running for over ten minutes now, and no sign of progress...).
[TestMethod]
public void Entry_IsCorrectlyMapped()
{
Action<PersistenceSpecification<Entry>> testAction = pspec => pspec
...
Where do you put unit tests for private functions in C# classes?
An article in Wikipedia suggests:
Putting tests in the same class as the members they're testing
Using partial classes
Personally, neither of these methods seem appropriate, and I much prefer to have unit tests located in a separate project altogether.
Any thoughts on...
My weekend project consists of writing a cross-platform concurrency primitives library (critical sections, read/write mutexes, interlocked integers, events, etc) and was wondering how to unit test this stuff. I realize that testing concurrent code is hard in itself, but testing the primitives of said code couldn't be that hard, could it?...
Recently I inherited a business critical project at work to "enhance". The code has been worked on and passed through many hands over the past five years. Consultants and full-time employees who are no longer with the company have butchered this very delicate and overly sensitive application. Most of us have to deal with legacy code o...
I have django code that interacts with request objects or user objects. For instance something like:
foo_model_instance = models.get_or_create_foo_from_user(request.user)
If you were going to test with the django python shell or in a unittest, what would you pass in there? Here simply a User object will do, but the need for a mock req...
I am a new to both Python and Django and I'm learning by creating a diet management site but I've been complete defeated by getting my unit tests to run. All the docs and blogs I've found say that as long as it's discoverable from tests.py, tests.py is in the same folder as models.py and you test class subclasses TestCase it should all ...
I've come across cppunit but it didn't look super-easy to use (maybe I didn't look hard, maybe because C++ doesn't work like Java/C#). Are there widely used, simple alternatives?
In fact, is cppunit the standard unit testing framework for C++?
...
I'm building a small JavaScript application in Adobe AIR and I'm looking for some general advice for automated unit testing.
I'd like to be able to run a suite of unit tests from the shell (maybe from a Makefile or similar).
My initial thought was to use something lightweight like jsUnity to run test scripts from within Rhino. I could ...
I'm working on a C# .net project using Visual Studio 2008, so my question is specifically for this case. However, the question should be the same to many other environments, so I'll be glad to hear opinions from people in similar environments.
My solution is organized in several projects. All of which have some belonging unit tests. Th...
I have WCF services structured like suggested by Miguel Castro. This means that I have set everything up manually, and have a console application hosting my services using ServiceHost objects.
I want to keep my service classes thin, and they are currently just passing on calls to behavior classes. My problem now is unit testing the ser...
I'm launching the NUnit gui from visual studio by setting the test project to start start nunit 2.5.3 as an external program. That loads the tests into the GUI but I still have to manually click the run button. Is there a command line argument that will have the tests run at the same time they're loaded?
...
Is there a 'standard' way to introduce assertions against Log4Net output?
E.g.
NUnit.Log4Net.Checkpoint()
...run some code that should not throw warnings...
NUnit.Log4Net.AssertNoErrors()
NUnit.Log4Net.AssertNoErrorsOrWarnings()
Or
NUnit.Log4Net.Checkpoint()
...code that warns user about an obsolete value...
NUnit.Log4Net.Asser...
I have a pyqt application that I'm writing unit tests for, and it relies heavily on signals and slots. To properly test it, I have to check that the correct signals are sent.
What is the best way to do this? I see that the Qt library has a QSignalSpy, but I can't find any reference to this in PyQt. The only option I can think of is to m...
public class Student
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
}
Student st1 = new...
I am writing a wrapper for the ConfigParser in Python to provide an easy interface for storing and retrieving application settings.
The wrapper has two methods, read and write, and a set of properties for the different application settings.
The write method is just a wrapper for the ConfigParser's write method with the addition of also...
Does anybody know what is called first if a test fails?
...
And I mean this in the easiest way. Say you have a function with the following signature:
public static Expression<Func<T, bool>> CreateExpression<T>(string value)
{
// ...
}
Usually it will create a more complex expression of some sort, but if the value is null the method should return a constant, always true expression. In other...
I have number of classes I've been asked to add some unit tests to with Rhino Mocks and having some issues.
First off, I know RhinoMocks doesn't allow for the mocking of Static members. I'm looking for what options I have (besides using TypeMock).
An example of the class I have is similar to the below:
class Example1 : ISomeInterface...
Let me qualify this question. I'm working on a "classic" ASP.NET application (Web Forms) that doesn't use Model-View-Presenter and was not written using TDD. It's also using an antiquated data access strategy (hand written DAO layer that invokes stored procs to populate and persist objects) that is unlikely to be upgraded to an ORM desp...