mardi 16 avril 2019

is controller testing functional testing?

I am really interested in different aspects of testing. I hope you can really read this and just give me your ideas if you have experience with this. Let's break down.

Fact 1: It's said that when we write a test from user perspective(going to uri, and getting results and if user sees the correct result, then test is right). They say this is called functional testing.

Sum up 1: So turns out when we write tests for controller, it's always functional as we must make the request to endpoint and observe the result. SO writing tests for controllers are always functional tests. Is that right?

==========================================================================

Fact 2: So, Integration testing is not controller testing. Let's imagine we have some functions (not controller functions) in our app. For example in our helper classes or models. and we want to test those functions like integration testing. So we won't mock anything and just test it.

Sum up 2: So, integration testing can be done on functions that are not controller functions, are written on other places(where request doesn't need to be done) and they must use external dependencies. By external dependencies, anything can be thought (such as file,database or another class itself) . Is that right?

==========================================================================

Sum up 3: what if I have just an api and instead of returning views, I return json and status codes from controllers. If i write test for controllers, it will still be called functional tests. right?

Aucun commentaire:

Enregistrer un commentaire