I'm attempting to write some unit tests using EasyMock and TestNG and have run into a question. Given the following:
void execute(Foo f) {
Bar b = new Bar()
b.setId(123);
f.setBar(b);
}
I'm trying to test that the Id of the Bar gets set accordingly in the following fashion:
@Test
void test_execute() {
Foo f = EasyMock.create...
I am using JUnit to write some higher level tests for legacy code that does not have unit tests.
Much of this code "swallows" a variety of unchecked exceptions like NullPointerExceptions (e.g., by just printing stack trace and returning null). Therefore the unit test can pass even through there is a cascade of disasters at various point...
I start with a test database containing the schema but with no data in the tables. I run a test like so
cd test/
ruby unit/directive_test.rb
I get failures indicating that the code found no data in the data tables. However, I look at the tables after running that test and the data is now in the the table. In fact, if I immediately ru...
I'm using VSTS 2K8 and I've set up a Unit Test Project. In it, I have a test class with a method that does a simple assertion. I'm using an Excel 2007 spreadsheet as my data source.
My test method looks like this:
[DataSource("System.Data.Odbc",
"Dsn=Excel Files;dbq=|DataDirectory|\\MyTestData.xlsx;defaultdir=C:\\Tes...
I'm trying to set up some unit tests for an existing compact framework class library. However, I've fallen at the first hurdle, where it appears that the test framework is unable to load the types involved (even though they're both in the class library being tested)
Test method MyLibrary.Tests.MyGenericClassTest.MyMethodTest threw ex...
I've performed the "Replace Method with Method Object" refactoring described by Beck.
Now, I have a class with a "run()" method and a bunch of member functions that decompose the computation into smaller units. How do I test those member functions?
My first idea is that my unit tests be basically copies of the "run()" method (with diff...
I never use unitests in my apps . I know that exists many technologies for testing .NET based application. (For example NUnit). Which of this tools more comfortable and more understandable to use. Please can you show the good articles where can I find information about unitests and understand key situation where I must use them?
...
I have an application that is supposed to read from the Registry and when executing a console application my registry access works perfectly.
However when I move it over to a test this returns null:
var masterKey = Registry.LocalMachine.OpenSubKey("path_to_my_key");
So my question is:
Does Visual Studio run Tests with a less privile...
There is good documentation out there on testing ActionMailer send methods which deliver mail.
But I'm unable to figure out how to test a receive method that is used to parse incoming mail.
I want to do something like this:
require 'test_helper'
class ReceiverTest < ActionMailer::TestCase
test "parse incoming mail" do
email = T...
From MBUnit I am trying to check if the values of two objects are the same using
Assert.AreSame(RawDataRow, result);
However I am getting the following fail:
Expected Value & Actual Value : {RawDataRow: CentreID = "CentreID1",
CentreLearnerRef = "CentreLearnerRef1",
ContactID = 1, DOB = 2010-05-05T00:00:00.0000000,
Email = "Email1",...
I'm in the process of writing a python module that includes some samples. These samples aren't unit-tests, and they are too long and complex to be doctests. I'm interested in best practices for automatically checking that these samples run.
My current project layout is pretty standard, except that there is an extra top level makefile th...
I have a bean that has a couple of beans injected with the autowire annotation (no qualifier). Now, for testing reasons I want to inject some mocks to the bean instead of the ones being autowired (some DAOs). Is there any way I can change which bean is being injected without modifying my bean? I don't like the idea of adding annotations ...
Hi,
when i run multiple JUnit tests in a row, does JUnit create a new thread for each execution or everything is wrapped in a single thread?
Thanks
...
Our installer program is going to be installing a number of system services, under both Windows and UNIX, using JavaServiceWrapper. There will be a class responsible for creating JavaServiceWrapper config files, installing the services, etc.
Can I have some suggestions on how to unit-test this class?
...
My current project based in Asp .net makes considerable use of Http handlers to process various requests? So, is there any way by which I can test the functionality of each of the handlers using unit test cases? We are using Nunit and Moq framework to facilitate unit testing.
...
Consider a following chunk of service:
public class ProductService : IProductService {
private IProductRepository _productRepository;
// Some initlization stuff
public Product GetProduct(int id) {
try {
return _productRepository.GetProduct(id);
} catch (Exception e) {
// log, wrap then throw
...
Hi all, I have an project which is dependent on the another project. But now i want to create an unit test target for the main project. Is it possible? because it will be referring the files of its dependent project.
...
So here's the thing: I've got an app that I'm testing that uses LINQ to Entities (EF4/.NET4). The app binds to an implementation of the Contains method that ignores nulls and, due to the way the database is configured, ignores case. That works great.
However, when I call into the same methods from my unit tests, I'm passing in a fake co...
Hello,
I'm running a few unit tests that requires a connection to the database. When my test project get initialized, a snapshot of the database is created, and when tests are done the database gets restored back to the snapshot.
Here is the implementation:
[TestClass]
public static class AssemblyInitializer
{
[AssemblyInitialize(...
I have a function to test, under_test, and a set of expected input/output pairs:
[
(2, 332),
(234, 99213),
(9, 3),
# ...
]
I would like each one of these input/output pairs to be tested in its own test_* method. Is that possible?
This is sort of what I want, but forcing every single input/output pair into a single test:
class TestPr...