DUnit Testing in a Midas/DataSnap project
Asked Answered
H

2

2

How does one setup DUnit Testing in a Midas/DataSnap project in Delphi 2006

Edit

How does one set up a Dunit Test into a TRemoteDataModule The project wizard in Delphi 2006 does not work with TRemoteDataModule

Heighttopaper answered 29/10, 2008 at 18:54 Comment(0)
X
4

The question doesn't entirely make sense. Unit tests are performed in a separate project, not within your DataSnap server. Generally, tests which connect to a database are integration tests rather than unit tests. What is it, exactly that you want to test? If it's utility methods within, say, a TRemoteDataModule, you should extract those out into a separate class as class methods, and test them there. You should not have to instantiate an application server to perform unit tests.

Xylography answered 29/10, 2008 at 19:14 Comment(5)
I don't agree. Unit testing a Client/Server application with real Client/Server communication, multiple clients and multi processing is mandatory, IMHO. It's sometimes called "stress tests", and it's always worth it...Civvies
@A.Bouchez, where did I say that you shouldn't do integration tests? I didn't; you absolutely should do integration tests. But unit tests are different than integration tests!Xylography
@Craig agreed, however DUnit can be used to perform integration tests and I have not seen a Delphi tool yet which is specifically designed for automated integration testsRobyn
@mjn, we use TestComplete for this.Xylography
I agree with Craig. A test is not a unit test if it talks to a database, the file system, the network or any service beyond your application's control.Gadroon
G
2

Sorry for the terse answer above, the iPad posts whenever I hit return while editing a post.

dUnit is designed to perform unit testing, and what you are trying to do is NOT unit testing.

A test is not a unit test if:

  • It talks to the database
  • It communicates across the network
  • It touches the file system
  • It can't run at the same time as any of your other unit tests
  • You have to do special things to your environment (such as editing config files) to run it.
  • It can't run in isolation

If you follow the SOLID principles (especially the single responsibility principle), using dUnit to test your class (without testing the Midas/DataSnap related logic) should be reasonably simple. And really, you shouldn't need to test the Midas/DataSnap logic.

But there are ways to perform integration and behavioural tests on Delphi applications.

Personally, I wouldn't use TestComplete because it doesn't integrate well with any sort of CI server and the tests are stored in a proprietary binary format (which makes merging differences or maintaining changes in any source control system problematic).

You could try dSpec, but I'm not sure Jody Dawkins is maintaining it any more.

I have used the AutoIt BASIC scripting language directly on some projects, and also used its .NET assembly to drive a Delphi application using NUnit and C# on another. While not perfect, the NUnit / C# solution was more elegant than anything I'd seen for performing functional / behavioural testing Delphi applications. It did take some effort to get it setup though.

Gadroon answered 2/12, 2011 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.