I have a web application that I want to test(I know, I put TDD junkies to shame, I'm working on it). It has an AngularJS front end with a Struts2 backend. The AngularJs code communicates with the Struts2 code via REST calls. After mulling it over, I realized that whaterver happens in the backend doesn't matter as long as I recieve the proper data back from the REST calls on the frontend. Therefore, I realized that I could just use "Black Box" testing and only write the JS tests. What is your opinion of this decision?
The expression "Putting somebody or something to shame" means to be so much better at something that it makes the other party ashamed of how poorly they do that same thing compared to you. It doesn't seem like that's what you meant though.
Test running on the front end should test only the front end. If you're checking that the front end actually makes proper REST calls then run JS tests. If the check is for proper display of returned data, run JS tests. If you're testing whether a REST call is properly parsed and processed, test on the backend.
In my opinion, JS testing should be far less than backend testing. If you do mostly JS testing even for things you shouldn't test with JS, then proper backend testing will put you to shame.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
Now that I think about it and after reading your response, I believe back end testing is the way to go, with some basic JS testing. My theory was that testing JS would also test the back end and it probably would. But why not just test the backend directly. And like you seem to suggest, backend is probably more effective.
Regarding the use of "putting to shame". I did indeed use it incorrectly. Thanks for the correction. Should have tested my question?
Read as much as you can on the uses, advantages, and downsides of both methods and make the right choice.
And I agree with your method,stick to black-box testing and test only public methods.Whenever a public behavior is checked, the private implementation is also implicitly tested and your tests will break only if there is a certain problem.
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad: