Closed lxaw closed 1 year ago
In a pure behavior test you run the full webapp on your laptop and then run another program (the behavior tests) that drives a web Browser, like chrome, and pretends to be user using your app.
React provides libraries to test "components". This is kinda like a Behavior test, but not really as you are not testing the full app. They only run part of the code. For example, they let you draw a Component by mocking the database access (so, no, database does not need to be running).
But, they are OK for this class. Use them. We will consider them Behavior tests for this class.
@josemvidal Got it, thank you for the explanation. Will use the React tests.
With regards to the final deadline for tests, according to here it says "Multiple unit tests (even if they are silly). Multiple behavioral tests. Test the core functionality of the app."
I just want to make sure that what we are testing makes sense to test / is OK for this course. With regards to behavior tests, most of the time we are just passing in either data we know to be valid and then checking if it renders the component / if the properties are properly rendered, and then with the unit tests since we are using an API, we are mainly testing if objects with correct attributes get saved correctly and if have incorrect attributes provide a useful error. Is this what is intended? Just want to be sure. We are making more than one test now as in general test-oriented development saves headaches.
@josemvidal
Thanks!
Remember:
The goal of the automated tests is to catch bugs early, before they get to the user. When you have a large set of test cases you feel more confident that the change you made to your code will not break something else in the program.
So, when you add new code and the code works, but it breaks something else, then you know. Add a test right to check that thing that broke. Because, if you broke it, it is very likely that you will break it again in the future with another code change.
You cannot write good behavior tests until after the feature is implemented.
@josemvidal Got it, that makes sense. Thanks!
Good afternoon.
We are beginning to write behavior tests for our webapp. The webapp uses Django's REST Framework for backend and React for Frontend. When reading here, it mentions using Selenium or React testing. I am a little confused; should we be using React tests since React is our frontend, or should we be using Selenium? Does it make a difference in the end? The reason I ask is because there are certain actions that would require the database to be running, such as registration. When a user fills out the registration form and hits submit, it sends a POST request to the backend server and then based on the result of that the UI will change. Is this something that React tests will be able to mimic accurately?
Thanks!