Test – How to decide when and when not creating an integrated test

Is there a clear process for deciding what to create an integration test suite for in your code base? I’m saying… “This part of my code conforms to the A standard, so tests should be created. This part of my code conforms to the B standard, so tests should not be created.”

With The size of my Rails app has increased, and I have added some small features (compared to the overall structure), like a field on the user account, which indicates whether the user can create an appointment for himself or him or her to ask the parents to do so (I understand the meaning of this error may be important, but I just want to explain the nuances of the implementation of this feature).

Should integration testing be site-specific-as mentioned above? Or should they be more comprehensive and integrated? The “yes” or “no” transparent process created for integration testing is what I’m looking for. Does it exist?

There is no way to decide whether to write integration tests that can be used without thinking. Any real application has Challenge any rules for nuances and special situations. However, except in cases where you find it inappropriate, you can follow a general approach: use acceptance testing as the method of integration testing.

Side note: I’m doing “integration testing”, which means that the test will run multiple layers of code, not Rails-specific meanings, and most of these meanings are covered by better methods and tools. But , If you use Rails integration testing, my answer applies.

Acceptance testing captures important user flows. It is also an integration test that runs all layers of the application from the UI all the way to the backend. Behavior Driven Development (BDD) and similar methods drive development by writing acceptance tests for all important user flows. Acceptance tests are complicated to write and run slowly, so try to write the smallest number possible, which still defines all important user flows.

Choosing acceptance tests is an art, but the rule of thumb is that if two scenes involve different actors and/or different main system components (e.g. UI screens), they should have separate acceptance tests, if not , They are the same scenario with details. One acceptance test is enough.

Acceptance tests are very useful for communicating with stakeholders (i.e. recording requirements), so no matter what your other test strategies are, you You need them. However, you will usually find that a complete set of acceptance tests are all the integration tests you need. Detailed requirements that are not worthy of acceptance tests can be expressed in unit tests.

In your example, I might Write an acceptance test for the scenario where users create their own appointments, and another for scenarios where the parent must help, because they will be completely different. The first one is (using Gherkin)

When I visit the new appointment page
And I create a new public appointment
And I visit my calendar
Then I see the public appointment

But second One is completely different:

When there is an unrestricted user "Dad"
And there is a restricted user "B illy" supervised by "Dad"
And there is a user "Stalker"
When "Billy" visits the new appointment page
And "Billy" creates a new appointment
And " Billy" visits his calendar
Then "Billy" sees a pending appointment

When "Stalker" visits "Billy"'s calendar
Then "Stalker" does not see an appointment< br />
When "Dad" visits "Billy"'s calendar
And "Dad" approves the pending appointment
Then "Dad" sees an appointment

When "Billy" visits his calendar
Then "Billy" sees an appointment

When "Stalker" visits "Billy"'s calendar
Then "Stalker" does not see an appointment< /pre>

On the other hand, for scenarios with and without positions, I may not write two different acceptance tests (assuming the position is just a text field that may or may not be filled). Unit tests may be sufficient Yes.

Is there a clear process for determining the content of your code base for which an integration test suite should be created? I'm saying... "This part of my code conforms to the A standard, so tests should be created. This part of my code conforms to the B standard, so tests should not be created."

With The size of my Rails app has increased, and I have added some small features (compared to the overall structure), like a field on the user account, which indicates whether the user can create an appointment for himself or him or her to ask the parents to do so (I understand the meaning of this error may be important, but I just want to explain the nuances of the implementation of this feature).

Should integration testing be site-specific-as mentioned above? Or should they be more comprehensive and integrated? The "yes" or "no" transparent process created for integration testing is what I'm looking for. Does it exist?

There is no way to decide whether to write integration tests that can be used without thinking. Any real application has nuances and special circumstances that challenge any rules. However, Except in cases where you find it inappropriate, you can follow a general method: use acceptance testing as the method of integration testing.

Side note: I’m doing "integration testing", This means that the test runs through multiple layers of code, not Rails-specific meanings, and most of these meanings are covered by better methods and tools. However, if you use Rails integration tests, my answer applies .

Acceptance testing captures important user flows. It is also an integration test, from the UI all the way to the back-end running all layers of the application. Behavior-driven development (BDD) and similar methods by writing all important users Flow acceptance tests to drive development. Acceptance tests are complicated to write and run slowly, so try to write the smallest number possible, which still defines all important user processes.

Choosing acceptance tests is an art. , But the rule of thumb is that if two scenes involve different actors and/or different main system components (e.g. UI screens), they should have separate acceptance tests. If not, they are the same scene with details. Enough.

Acceptance tests are very useful for communicating with stakeholders (i.e. recording requirements), so no matter what your other testing strategies are, you will need them. However, you will usually find a full set of acceptance tests Is all the integration tests you need. Detailed requirements that are not worthy of acceptance testing can be expressed in unit tests.

In your example, I might write an acceptance test for the scenario where users create their own appointments , And the other is used for scenarios where the parent must help, because they will be completely different. The first one is (using Gherkin)

When I visit the new appointment page
And I create a new public appointment
And I visit my calendar
Then I see the public appointment

But the second one is completely different:

When there is an unrestricted user "Dad"
And there is a restricted user "Billy" supervised by "Dad"
And there is a user "Stalker"< br />When "Billy" visits the new appointment page
And "Billy" creates a new appointment
And "Billy" visits his calendar
Then "Billy" sees a pending appointment

When "Stalker" visits "Billy"'s calendar
Then "Stalker" does not see an appointment

When "Dad" visits "Billy"'s calendar
And "Dad" approves the pending appointment
Then "Dad" sees an appointment

When "Billy" visits his calendar
Then "Billy" sees an appointment

When "Stalker" visits "Billy"'s calendar
Then "Stalker" does not see an appointment

On the other hand, for scenes with and without locations, I might Will not write two different acceptance tests (assuming that the location is just a text field that may or may not be filled). A unit test may be sufficient.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2363 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.