To edit or add content to this Wiki, you can simply create a new account at http://wocommunity.org/account.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: adding section on testing with db access

...

If there are questions about this testing, please send mail to the Project WOnder mailing list and/or to kiddyr@users.sourceforge.net.

Adding Tests That Need Database Access

There are support methods in the er.extensions.ERExtensionsTest class that make it possible to use databases and to test against real data in the junit tests. If you add tests that can fetch and manipulate data, consider parameterizing your test class. This can be done by creating a "testAll" method in the test, and then having a static inner class that actually contains the tests. The "testAll" method can dynamically add methods to the existing TestSuite. See ERXEOAccessUtilitiesTest for an example of how this can be done.

In order to make the data access in the tests, add information to your ~/Library/wobuild.properties file:

Code Block

    wonder.test.MySQL.url=jdbc:mysql://localhost/testingJunk
    wonder.test.MySQL.user=ray
    wonder.test.MySQL.pwd=aPassword


For now, the availableAdaptorNames() static method in the er.extensions.ERExtensionsTest class must also be changed. By default, the tests use only the "Memory" adaptor. It would be wonderful if one could run tests against the "Memory" adaptor and then against the "MySQL" adaptor, for instance. Right now, if one does this, tests fail in strange ways. This will be fixed when we can re-initialize EOF correctly. So, to use "MySQL", one would change the availableAdaptorNames() method from:

Code Block

public static NSArray<String> availableAdaptorNames() { return new NSArray<String>(); }

to:

Code Block

public static NSArray<String> availableAdaptorNames() { return new NSArray<String>("MySQL"); }

When there is something available in this array, the "Memory" adaptor will not be used by the test classes, so the tests will pass either way.