Single Assertion vs multiple assertions

Source: Internet
Author: User

Stst

To discuss with you, just one assertion in a test case
Or is it a use case to do multiple related assertions

For example, there is a query function (ID)? Return [Name, gender, age]

So is it good to assert these three attributes in a test case?

Or is it good to assert each attribute in three test cases?

Hz

Three Check one use case

You want to have 10 questions each time you tell a person to toss 10 times or to tell you 10 toss 1 times at a time

Stst

Oh, but I found it to be written separately, more expressive.

You said "Toss" of course, but sacrifice the expression of the power

Stst

Now the discussion is divided into two factions, if you can express the best

I'm more supportive of this faction, but I can't refute the previous faction.

Crs

Your 3 attributes are obtained by a single behavior: Why write 3 of ...

Stst I'm feeling a little more expressive.

Crs

Then why not take the 3 verification of a method. If it's necessary to smoke.

Stst

If query is more complicated, the names, genders, and ages come from a complex algorithm, is it easier to express the trace apart?

WL

How do you know that these three attributes are not relevant, and three use cases are verified correctly and not equal to all correct at the time of removal?

Stst

Well, yes, very insightful.

This can be explained in this way.

I'm very much in agreement with this statement now.

In the concept itself as a unit, a concept itself has several attributes, which should be put together with assertions, but should not assert several concepts at the same time

WL

Agree

Stst

In other words, it is not possible to assert two concepts in a test

such as execution

Insert (...)

Assert the result of insert

Query ()

Assert the result of query
Because the result of the insert and the result of the query are two unrelated concepts, it should not be put in a test to assert
That's what I understand.

WL

Brother Sai is very good at abstract summary, I think, insert and query is two independent test, if it is another new test, usually with business association, otherwise there is no need to put together, put together after the test direction is not the same

Stst

I'm flattered, I like it.

Well, the question goes on again, and it's a matter of principle in oox.
Single duty: One module to do the only thing
It feels good to use it here too: a test only asserts one thing, why putting insert and query in a test case is bad because a test asserts two things

LF

Doing the right thing, not doing it right

Stst

Well, and it's just the right thing to do.

Single Assertion vs multiple assertions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.