DUnit Testing in a Midas/DataSnap project

怎甘沉沦 提交于 2019-12-06 10:42:51

问题


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


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/247978/dunit-testing-in-a-midas-datasnap-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!