Jump to content

Abstract classes for testing code?


Rommeo

Recommended Posts

Hello,

 

I went to a new job meeting today and the guy there told me that they use abstract classes for testing classes/codes. Well I would create a simple html file and test the classes and functions if they return me the correct values. So why would i need an abstract class for testing purpose? Is there any point that i am missing, or he does not know what he talks about?

 

Thank you in advance for your replies.

Link to comment
Share on other sites

What do you mean by "create a simple html file and test the classes"?
A html file would not run your php code; are you talking about implementing a simple view and doing manual testing, or making the html file call endpoints and do end-to-end testing?

 

Either way sounds as if it's not enough to test code well.

Manual testing is pretty expensive, as in it takes a lot of time, and only reliable in some aspects.

 

It's much more important to have good automated tests.

Automated tests allow you to write test-first (TDD) code, which is a very effective way to reduce bugs.

 

 

I'm not sure what they mean by using abstract classes. It sounds a bit weird.

Are they saying they extends an abstract base class? (Like PhpUnit's TestCase class) That would make more sense.

 

You can then extend that abstract class and use its assertion methods to test your code. For an example, take a look at these.

Link to comment
Share on other sites

My mistake. I was gonna say a simple php file. I meant (i m not a php expert), at the last place I was working, we were creating simple php files, set the values in and call the classes and functions and see the results. It was a small company.

 

It sounded me weird too when the guy told me that, I don't need to make the class abstract to test the code (as far as i know). So what's the point. Well I think he does not know what he talks about.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.