3

I'm writing some new code that involves POP3 manipulation. I'm trying to come up with a design that allows me to write tests, so it's fairly decoupled and exercises most of the new code I'm writing.

The problem I'm facing is that I still need to verify that the way I'm using some third party component for email is the right one. This involves testing, for example, strange responses from faulty POP3 servers.

Right now, I'm using a mock POP3 client so I can test the logic around a possible scenario where the client gets either an error or a strange response. However, I still need to check that these assumptions are true and remain true after, for example, an upgrade of the third party components.

Also, there's SMTP. I know in the Java world you have Dumbster.

What are my alternatives in Delphi? Write my own custom mini-servers using the usual suspects?

Leonardo Herrera
  • 8,388
  • 5
  • 36
  • 66
  • AH yes, not a duplicate, but essentially the same thing, just take out SMTP or POP3 and insert HTTP: http://stackoverflow.com/questions/9463011/http-server-for-unit-tests-in-delphi – Warren P May 09 '12 at 12:20
  • @WarrenP - I think having a separate executable is some form of horrible sacrilege according to the Holy Book O' Unit Testing or something. And the accepted answer in the link you provided is 'write your own server using Indy.' I was hoping somebody already done that. – Leonardo Herrera May 09 '12 at 13:30
  • @WarrenP - yes, I see. No need to scream. – Leonardo Herrera May 10 '12 at 14:02
  • I understand. So, this is integration testing. I still want to do it in an easy way, so any developer touching this code doesn't see it fail, blame the external dependency and move on. I'm guilty of doing that when testing against external SOAP services failed, for example. – Leonardo Herrera May 10 '12 at 14:20
  • Such a developer should learn to use another tool to confirm that the service is up or down, such as Mozilla Thunderbird. – Warren P May 10 '12 at 18:08
  • They do. The question is, will they? If the automated test (note that I'm not using unit test anymore... see?) fails, they have to go elsewhere and do external setup. That's what I want to avoid. – Leonardo Herrera May 10 '12 at 19:21

1 Answers1

2

Well I hate to be the person to confirm what you suspect, but:

(a) you're going to have to build your own (everybody's needs are different, and at least in Delphi there are no standard fixtures for this kind of integration testing equivalent to the Java Dumpster) and...

(b) I don't think you should assume Indy, because ICS and Synapse are great, and using their demos might get you want you want even faster... I would go with ICS, given a choice. But if you know Indy better, then go with it.

(c) I tend to keep around a virtual machine running Linux, because I find it easy to test with the sort of POP3/SMTP servers that get actually used in the real world at ISPs around me, and if I cared about it, I'd probably create a VM for Windows + Exchange server, if I had MSDN licenses, and the ability to do so.

Remember this ain't unit testing no more. This is integration testing. Even if you cram it all in with threads instead of processes, that's no unit test you've got there, it's an integration test.

If you want all your developers to be able to test without setup, then create a QA-TEST-NETWORK BOX which is always available and which has various configurations on various standard ports, then your integration tests can run at any developer PC workstation with zero setup, inside your LAN. Outside your LAN, in a WAN environment this gets a lot hairier.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • Yup, was suspecting this much. I love Synapse, but I don't think it have classes for POP3 or SMTP servers. Never used ICS, will take a look. Also, as I explained in another comment, I don't want to have external dependencies - I want to avoid friction when possible. – Leonardo Herrera May 10 '12 at 19:24
  • 1
    Update: I created a POP3 mock server using Indy. I start the server during initialization, then in the tests the client connects to localhost and that's it. It works great (I even managed to catch a couple of bugs in my pop3 library that got reported to my provider, and they fixed them right away!) – Leonardo Herrera May 22 '12 at 18:56