I quote this post from exubero's entry. I think this entry will benefit everyone who is doing a unit test:
There are a large number of different methods beginning with assert defined in Junit's Assert class. Each of these methods has slightly different arguments and semantics about what they are asserting.
The following shows some irr...
I'm working with Symfony + Doctrine + PHPUnit, with NetBeans IDE. Here' my current approach to unit testing.
setUp() function loads the test fixtures from .yml files
tearDown() function delete all data from models. this is done by looping through an array of all my models' names to something like Doctrine_Query::delete($modelName)->exe...
Hi All,
I am unit testing some code that interactes with a repository, that takes an expression (Expression<Func<Entity, bool>>) to filter the results, like so:
int orderId = 10;
_respository.GetFiltered(order => order.Id == orderId);
I am having a problem Unit Testing, more specifically setting up expectations that an expression wi...
i am required to use mockito to create unit testing framework for existing code. I am unable to find a good place to get started with learning Mockito. Could you please point me to a good learning resource for mockito? (online resource or otherwise)
...
hi
i have old code which didnt use TDD
now i want to write a test for a function which looks like this
function somefunction($someargs){
// do a few checks on $someargs
$database = new DB_PG();
$result = $database->select($query);
// do some changes on result
return $result;
}
since im not much expirienced with ph...
I'm using Python's built-in unittest module and I want to write a few tests that are not critical.
I mean, if my program passes such tests, that's great! However, if it doesn't pass, it's not really a problem, the program will still work.
For example, my program is designed to work with a custom type "A". If it fails to work with "A", ...
We need to migrate a unit test harness developed with C# and NUnit to C++ running on Red Hat Linux.
We want to minimize the efforts in migration.
We are reading resources such as this:
http://gamesfromwithin.com/exploring-the-c-unit-testing-framework-jungle
But we don't see anything similar to NUnit.
...
I am attempting to unit test a WCF host management engine that I have written. The engine basically creates ServiceHost instances on the fly based on configuration. This allows us to dynamically reconfigure which services are available without having to bring all of them down and restart them whenever a new service is added or an old one...
In my application, I have two equivalent enums. One lives in the DAL, the other in the service contract layer. They have the same name (but are in different namespaces), and should have the same members and values.
I'd like to write a unit test that enforces this. So far, I've got the following:
public static class EnumAssert
{
pub...
Hi,
I have a problem related to creating an instance of a WCF ServiceHost withing a set of unit tests and a project that is build within an integration build in TFSBuild. The code used in the unit test is:
[TestMethod]
public void Service_Can_Be_Dynamically_Hosted()
{
ServiceHost host = new ServiceHost(typeof(DiscoveryService));
...
I'm trying to unit test, using VS unit testing facility following method.
void Get(string name, Action<string> callBack);
here is unit tester
[TestMethod]
public void Test()
{
Action<string> cb = name =>
{
Assert.IsNotNull(name);
};
var d = new MyClass();
d.Get("tes...
Say I have a unit test that wants to compare two complex for objects for equality. The objects contains many other deeply nested objects. All of the objects' classes have correctly defined equals() methods.
This isn't difficult:
@Test
public void objectEquality() {
Object o1 = ...
Object o2 = ...
assertEquals(o1, o2);
}
...
In Visual Studio, I just created a simple Unit Test to test a method I wrote. I wanted to check the code coverage, but the Code Coverage window only ever states that "Code Coverage is not enabled for this test run". Why? Note:
I've already followed the instructions on this page, i.e. the test configuration does have the relevant assemb...
If an assembly contains an app.config file, ConfigurationManager will load it as long as it is in the same directory as the NUnit project that is executing through NUnit-Gui. To illustrate consider the following folder structure.
+ TestFolder
testProject.nunit
+ AssemblyAFolder
assemblyA.dll
assemblyA.dll.config
+ A...
I'm trying to write a test for an ASP.NET MVC controller method. I've got RhinoMocks (since it seems to be the most popular and best supported), and MvcMockHelpers (since it seems like I need that).
My test method looks like:
var controller = new MyController();
MvcMockHelpers.SetFakeControllerContext(mocks, controller);
mocks.ReplayA...
I've spent a lot of time building out tests for my latest project, and I'm really not sure what the ROI was on the time spent.
I'm a one man operation, and I'm building web applications. I don't necessarily have to "prove" that my software works to anyone (except my users), and I'm worried that I spent a good deal of time needlessly ...
I have a PHPUnit Test class that I'd like to be ignored from a test run. I know I can do it by renaming it so that it doesn't contain the word Test in its filename, but I'd rather not do that since it muddies up the source control waters more than I'd like.
Does anyone have a suggestion?
...
During a recent interview I was asked why one would want to create mock objects. My answer went something like, "Take a database--if you're writing test code, you may not want that test hooked up live to the production database where actual operations will be performed."
Judging by response, my answer clearly was not what the interview...
I have script called Script.php and tests for it in Tests/Script.php, but when I run phpunit Tests it does not execute any tests in my test file. How do I run all my tests with phpunit?
PHPUnit 3.3.17, PHP 5.2.6-3ubuntu4.2, latest Ubuntu
Output:
$ phpunit Tests
PHPUnit 3.3.17 by Sebastian Bergmann.
Time: 0 seconds
OK (0 tests, 0 asser...
What is the best way to test value visibility between threads?
class X {
private volatile Object ref;
public Object getRef() {
return ref;
}
public void setRef(Object newRef) {
this.ref = newRef;
}
}
The class X exposes a reference to the ref object. If concurrent threads read and and write the object reference every Thread...