What I meant is that the tests you write have to have some knowledge
about the data in the database. (should equal (2) in the example.)

If you have a configuration like:

country:
- id: 1, name: "Canada"

how do you check that the software under test loads it correctly
without repeating the data in your tests?

I found an old article about dbunit 
http://onjava.com/pub/a/onjava/2004/01/21/dbunit.html
with this example.

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
  <EMPLOYEE employee_uid='1'
            start_date='2001-01-01'
            first_name='Drew' ssn='333-29-9999'
            last_name='Smith' />
  <EMPLOYEE employee_uid='2'
            start_date='2002-04-04'
            first_name='Nick' ssn='222-90-1111'
            last_name='Marquiss' />
  <EMPLOYEE employee_uid='3'
            start_date='2003-06-03'
            first_name='Jose' ssn='111-67-2222'
            last_name='Whitson' />
</dataset>

public void testFindBySSN() throws Exception{

  EmployeeFacade facade = //obtain somehow

  EmployeeValueObject vo =
    facade.getEmployeeBySocialSecNum("333-29-9999");

  TestCase.assertNotNull("vo shouldn't be null", vo);
  TestCase.assertEquals("should be Drew",
     "Drew", vo.getFirstName());
  TestCase.assertEquals("should be Smith",
     "Smith", vo.getLastName());
}

One way around this problem would be to copy the actual result in an
IDataSet compare it to a expected IDataSet that is loaded from a
distinct file. (The ids would still be redundant.) The problem with
this approach is the overhead to copy the data (correctly),
maintaining an additional set of expected result files and that the
test is less readable.

Do you have a solution for this problem?

Thomas


On Oct 22, 4:52 pm, Ken Egervari <ken.egerv...@gmail.com> wrote:
> That test is just to verify that scaladbtest did in fact insert the
> rows in the database. It's testing to make it is doing what it's
> supposed to do ;)
>
> As an application developer, you will not have to assert that
> scaladbtest has loaded your data - you can just make it use of it when
> your test starts.
>
> Does that answer your question?
>
> On Oct 22, 10:05 am, Thomas Jung <thomas.andreas.j...@googlemail.com>
> wrote:
>
>
>
> > Hi Ken,
>
> > How do you use DBUnit or ScalaDBTest without introducing redundancy
> > all over the place?
>
> > The knowledge about the data is in the files and to some extend in
> > your tests as well.
> > For example from your test suite:
>
> > tester.onBefore("two_string_table.dbt")
> > jdbcTemplate.queryForInt("select count(*) from two_string_table")
> > should equal (2)
>
> > Thomas
>
> > On Oct 21, 5:45 pm, Ken Egervari <ken.egerv...@gmail.com> wrote:
>
> > > Hi guys,
>
> > > I wrote a framework that intends to replace DBUnit. It promises a 30%
> > > reduction in the number of characters used compared to dbunit, and
> > > mass simplifications and extra features across the board.
>
> > > It's on git. You can read about it 
> > > there:http://github.com/egervari/scaladbtest
>
> > > I only spent 2 or 3 days on it so far, but all the basic functionality
> > > is there and it works with mysql and hsqldb for sure. I even have it
> > > working on a real project that has 1093 tests and hundreds of records
> > > of test data, so it's field tested ;) It actually runs faster than
> > > dbunit too by about 10 seconds :)
>
> > > Enjoy,
>
> > > Ken

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javapo...@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to