-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add documentation for {fail,Reason}
to ct test case return values
#7869
Conversation
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 |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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)?
There was a problem hiding this 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 |
There was a problem hiding this comment.
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)?
lib/common_test/doc/src/ct_suite.xml
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
{comment, Comment}
paragraph is not explicitly suggesting "The test case is considered successful, but with a comment."- "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 ;-).
I think @u3s's suggestions make sense, if @IngelaAndin agrees I will break up the single paragraph and augment the docs for more clarity? |
@Maria-12648430 sure go ahead. I think my suggestion was a small improvement but @u3s idea will end up being a bigger improvement. |
a3e628c
to
6216c9f
Compare
CT Test Results 2 files 58 suites 1h 24m 20s ⏱️ 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 |
I pushed a first draft for the |
lib/common_test/doc/src/ct_suite.xml
Outdated
|
||
<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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, agreed 👍
There was a problem hiding this comment.
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.
lib/common_test/doc/src/ct_suite.xml
Outdated
successful test cases.</p> | ||
|
||
<p>If the test case function crashes or exits purposely, it is considered | ||
failed.</p> |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 =^^=
I like proposed format and also agree with comments made by Ingela. |
510351a
to
1d78256
Compare
Last commit adapts the detailed return value documentation for the User Guide. |
There was a problem hiding this 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!
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. |
Sure, good idea :) |
There, is that better? 😺 |
Thanks for PR |
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 thect_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.