Rommeo Posted January 26, 2018 Share Posted January 26, 2018 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. Quote Link to comment https://forums.phpfreaks.com/topic/306340-abstract-classes-for-testing-code/ Share on other sites More sharing options...
Stratadox Posted January 26, 2018 Share Posted January 26, 2018 (edited) 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. Edited January 26, 2018 by Stratadox Quote Link to comment https://forums.phpfreaks.com/topic/306340-abstract-classes-for-testing-code/#findComment-1555792 Share on other sites More sharing options...
Rommeo Posted January 27, 2018 Author Share Posted January 27, 2018 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. Quote Link to comment https://forums.phpfreaks.com/topic/306340-abstract-classes-for-testing-code/#findComment-1555798 Share on other sites More sharing options...
BigB Posted January 27, 2018 Share Posted January 27, 2018 (edited) Just a guess, abstract class -> abstract method, this way you're always got the error checking code running before you access the rest of the classes/methods. So any instance will automatically call the error method first etc. Link might be helpful (Even if Java): http://www.javacoffeebreak.com/faq/faq0084.html Edited January 27, 2018 by BigB Quote Link to comment https://forums.phpfreaks.com/topic/306340-abstract-classes-for-testing-code/#findComment-1555804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.