Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for {fail,Reason} to ct test case return values #7869

Merged

Conversation

Maria-12648430
Copy link
Contributor

In the course of #7824 it was discovered that when a test case returns {fail, Reason} the test case is considered failed. This return value is explicitly used by the property testing facility of ct to indicate failing properties.

However, the docs for ct_suite do not mention it, and as it stands, this passage in the ct_suite docs reading "If the function returns anything else [except {skip, Reason}], the test case is considered successful." and this passage in the User Guide reading "If the test case function crashes or exits purposely, it is considered failed. If it returns a value (no matter what value), it is considered successful. An exception to this rule is the return value {skip,Reason}." contradict reality.

@u3s u3s added team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI labels Nov 16, 2023
@u3s u3s self-assigned this Nov 16, 2023
considered successful. An exception to this rule is the return value
<p>If the test case function crashes, exits purposely or returns <c>{fail,Reason}</c>,
it is considered <em>failed</em>. If it returns any other value (no matter what value),
it is considered successful. An exception to this rule is the return value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are improving this I was thinking maybe we should rephrase to

"If {skip, Reason} is returned the test case will be skipped and the Reason logged, otherwise if it returns any other value (no matter what value), the test case is considered successful." I think it sounds better!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think return value of a testcase is an important part of this section and possibly being common reason people visiting this chapter. IMHO having single paragraph for describing all possibilities is not optimal here and not easy to find when not reading sequentially.

Maybe we could use some form of enumeration to make it more visible what return value could be and how it will be interpreted (similarly to how it is explained in previous init/end_per_testcase section)?

@IngelaAndin IngelaAndin self-requested a review November 28, 2023 08:57
Copy link
Contributor

@IngelaAndin IngelaAndin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested rephrasing, see code comment!

considered successful. An exception to this rule is the return value
<p>If the test case function crashes, exits purposely or returns <c>{fail,Reason}</c>,
it is considered <em>failed</em>. If it returns any other value (no matter what value),
it is considered successful. An exception to this rule is the return value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think return value of a testcase is an important part of this section and possibly being common reason people visiting this chapter. IMHO having single paragraph for describing all possibilities is not optimal here and not easy to find when not reading sequentially.

Maybe we could use some form of enumeration to make it more visible what return value could be and how it will be interpreted (similarly to how it is explained in previous init/end_per_testcase section)?

@@ -604,6 +604,9 @@
<p>To print some information in field <c>Comment</c> on the HTML
result page, return <c>{comment, Comment}</c>.</p>

<p>If the function returns <c>{fail, Reason}</c>, the test case
is considered as failed.</p>

<p>If the function returns anything else, the test case is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing this part, maybe we could improve clarity here as well ... I hope :-)
It think this is not as clear about {comment, Comment} as it should/could be. What do you think?

  1. {comment, Comment} paragraph is not explicitly suggesting "The test case is considered successful, but with a comment."
  2. "If the function returns anything else, the test case is considered successful.". When people learn and can't absorb all information or just skim docs, I'm afraid they might draw a conclusion that a testcase returning {comment, Comment} will not be considered successful.

Maybe I'm picky here, but I had students asking those questions :-) It would be great if I could redirect them to clear docs instead of explaining it myself ;-).

@IngelaAndin IngelaAndin added the waiting waiting for changes/input from author label Nov 28, 2023
@Maria-12648430
Copy link
Contributor Author

I think @u3s's suggestions make sense, if @IngelaAndin agrees I will break up the single paragraph and augment the docs for more clarity?

@IngelaAndin
Copy link
Contributor

@Maria-12648430 sure go ahead. I think my suggestion was a small improvement but @u3s idea will end up being a bigger improvement.

@Maria-12648430 Maria-12648430 force-pushed the fix_ct_testcase_return_docs branch from a3e628c to 6216c9f Compare November 29, 2023 12:43
Copy link
Contributor

github-actions bot commented Nov 29, 2023

CT Test Results

    2 files    58 suites   1h 24m 20s ⏱️
450 tests 438 ✔️ 12 💤 0
485 runs  470 ✔️ 15 💤 0

Results for commit 409df69.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@Maria-12648430
Copy link
Contributor Author

I pushed a first draft for the ct_suite docs, for review. If you agree with this, I will do the respective paragraph in the user guide along the same lines.


<p>If the function returns any other term, the test case is considered
successful. It is common practice to explicitly return <c>ok</c> from
successful test cases.</p>
Copy link
Contributor

@IngelaAndin IngelaAndin Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to spread that practice, even though it is quite used it can be very useful not to return ok as you can then see in the log what was the result of the last action in the test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, agreed 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the sentence in the last commit.

successful test cases.</p>

<p>If the test case function crashes or exits purposely, it is considered
failed.</p>
Copy link
Contributor

@IngelaAndin IngelaAndin Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exits purposely is a lite vague! When the test case code ends the test case process will exit purposely with the reason normal and it will be successful, if it exits not normal either by crashing or by calling ct:fail the test case will fail. (Additionally it will also fail if it returns {fail, Reason} as we now know)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the phrase used in the user guide, I just kinda copied that. But I agree 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "or exits purposely" in last commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well our documentation is far from perfect ;-) I think we should strive for continuous improvement :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think it is pretty good actually :) But we can always improve.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well every ting is relative, and of course many parts are really good but I believe there is still room for improvement in some places more than others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course :) Generally, the reference is pretty good I think. "This is what it expects, this is what it does, this is what you get", nice and concise. The User Guide is another thing, and not an easy one, as much of what is (not) important depends on the reader, so what is too vague for one reader may be too pedantic or long-winded to another. I always struggle when I have to write something in there =^^=

@u3s
Copy link
Contributor

u3s commented Nov 29, 2023

I pushed a first draft for the ct_suite docs, for review. If you agree with this, I will do the respective paragraph in the user guide along the same lines.

I like proposed format and also agree with comments made by Ingela.

@Maria-12648430 Maria-12648430 force-pushed the fix_ct_testcase_return_docs branch from 510351a to 1d78256 Compare November 29, 2023 16:57
@Maria-12648430
Copy link
Contributor Author

Last commit adapts the detailed return value documentation for the User Guide.

Copy link
Contributor

@u3s u3s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making a more general improvement!

@IngelaAndin
Copy link
Contributor

I like what you wrote but not that it will be duplicated in the user guide. Could we not let the user guide link to man page.
Write something like. The test case result can be customized in several ways see manual for details.

@Maria-12648430
Copy link
Contributor Author

Could we not let the user guide link to man page.

Sure, good idea :)

@Maria-12648430
Copy link
Contributor Author

There, is that better? 😺

@IngelaAndin IngelaAndin removed the waiting waiting for changes/input from author label Dec 1, 2023
@IngelaAndin IngelaAndin merged commit c5b8188 into erlang:master Dec 4, 2023
15 checks passed
@IngelaAndin
Copy link
Contributor

Thanks for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:low team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants