Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to test a Delphi application

I have a Delphi application that has many dependencies, and it would be difficult to refactor it to use DUnit (it's huge), so I was thinking about using something like AutomatedQA's TestComplete to do the testing from the front-end UI.

My main problem is that a bugfix or new feature sometimes breaks old code that was previously tested (manually), and used to work.

I have setup the application to use command-line switches to open-up a specific form that could be tested, and I can create a set of values and clicks needed to be done.

But I have a few questions before I do anything drastic... (and before purchasing anything)

  1. Is it worth it?
  2. Would this be a good way to test?
  3. The result of the test should in my database (Oracle), is there an easy way in testcomplete to check these values (multiple fields in multiple tables)?
  4. I would need to setup a test database to do all the automated testing, would there be an easy way to automate re-setting the test db? Other than drop user cascade, create user,..., impdp.
  5. Is there a way in testcomplete to specify command-line parameters for an exe?
  6. Does anybody have any similar experiences.
like image 615
Osama Al-Maadeed Avatar asked Feb 12 '09 09:02

Osama Al-Maadeed


3 Answers

I would suggest you plan to use both DUnit and something like TestComplete, as they each serve a different purpose.

DUnit is great for Unit Testing, but is difficult to use for overall application testing and UI testing.

TestComplete is one of the few automated testing products that actually has support for Delphi, and our QA Engineer tells me that their support is very good.

Be aware though that setting up automated testing is a large and time-consuming job. If you rigourously apply unit testing and auomated UI testing, you could easily end up with more test code than production code.

With a large (existing) application you're in a difficult situation with regards to implementing automated testing.

My recommendation is to set up Unit Testing first, in conjunction with an automated build server. Every time someone checks anything in to source control, the Unit Tests get run automatically. DO NOT try to set up unit tests for everything straight up - it's just too big an effort for an existing application. Just remember to create unit tests whenever you are adding new functionality, and whenever you are about to make changes. I also strongly suggest that whenever a bug is reported that you create a unit test that reproduces the bug BEFORE you fix it.

like image 154
Alistair Ward Avatar answered Oct 24 '22 07:10

Alistair Ward


I'm in a similar situation. (Large app with lots of dependencies). There is almost no automated testing. But there is a big wish to fix this issue. And that's why we are going to tackle some of the problems with each new release.

We are about to release the first version of the new product. And the first signs are good. But it was a lot of work. So next release we sure need some way to automate the test process. That's why I'm already introducing unit tests. Although due to the dependencies, these are no real unit tests, but you have to start somewhere.

Things we have done:

  • Introduced a more OO approach, because a big part the code was still procedural.
  • Moved stuff between files.
  • Eliminated dependencies where possible.

But there is far more on the list of requirements, ensuring enough work for the entire team until retirement.

And maybe I'm a bit strange, but cleaning up code can be fun. Refactoring without unit tests is a dangerous undertaking, especially if there are a lot of side effects. We used pair programming to avoid stupid mistakes. And lots of test sessions. But in the end we have cleaner code, and the amount of new bugs introduced was extremely low.

Oh, and be sure that you know this is an expensive process. It takes lots of time. And you have to fight the tendency to tackle more than one problem in a row.

like image 20
Toon Krijthe Avatar answered Oct 24 '22 07:10

Toon Krijthe


I can't answer everything, as I've never used testcomplete, but I can answer some of those.

1 - Yes. Regression testing is worth it. It's quite embarrassing to you as a developer when the client comes back to you when you've broken something that used to work. Always a good idea to make sure everything that used to work, still does.

4 - Oracle has something called Flashback which lets you create a restore point in the database. After you've done your testing you can just jump back to this restore point. You can write scripts to use it too, FLASHBACK DATABASE TO TIMESTAMP (FEB-12-2009, 00:00:00);, etc

like image 3
Rich Adams Avatar answered Oct 24 '22 05:10

Rich Adams