Home > Net >  How to write unit tests? What is the meaning of his?
How to write unit tests? What is the meaning of his?

Time:11-05

Haven't written, project recently asked to write, my question is:
1. Like my input is A, through the algorithm S () function, b. output that is my question: my actual output is B, my expectation output C is according to the algorithm S () function. So the actual output and desired output C B has always been the same, how can I test

CodePudding user response:

CodePudding user response:

This requires a lot of test cases, because part of the right code is wrong,

CodePudding user response:

Conditions cover, do you think serious test was easy,

Coverage testing his tectonic conditions and according to the case of the use cases and scenarios, fight against scenario testing

CodePudding user response:

Writing test namely writing assertions

Then you will of assertion is

Assert conditions a output a
Assert condition b output b
No output does not support the assertion that a, b

CodePudding user response:

D unit tests belong to the white box testing, do 6 levels of coverage,

CodePudding user response:

reference 4 floor wanghui0380 response:
write test namely write assertions

Then you will of assertion is

Assert conditions a output a
Assert condition b output b
Asserts that a and b are not output does not support
didn't understand what you say,,, I know that unit testing is the assertion, but it is my problem is the actual output and I'm looking forward to the output of the C, b is calculated through the S () function, this want to test? Or how the approach of this test, won't appear this kind of circumstance

CodePudding user response:

refer to fifth floor I don't understand the computer replies:
d unit tests belong to the white box testing, do 6 levels of coverage,
can detailed say, or post a link

CodePudding user response:

"Write" on using a function, first take the time to think about how to write a test, and in the test cases to write something that you can think as much as possible, and then run the test "error first, subjects were again," don't come up to write a function code,

Good technical manager may often go to delete code, pay attention to is to remove the code, as long as the test runs without error, how programming stem from scratch, there is no acceptance of this code, they can consider to delete the code actually, so the technology to a certain Gao Gan degrees, is to remove unnecessary code, rather than piled up a lot of code out to show off,

CodePudding user response:

"That this do you want to test?" This kind of problem, you of the so-called "testing" is to finish writing the code in the hips, you are really gilding the lily, you don't feel pain, "" redundant"? The test code is often deceive ignorant of the director of test-driven development,

The real development, is don't know what to write, write tests first, and write "sick", to let the test can pass, each person every day when they have free run test hundreds of times, every change to run the test dozens of times to submit to the source code management system,

If you first write programs, for larger systems developers and architects, it's like a special forces do not have any action plan, is the small white to die,

CodePudding user response:

Test is also simple and complex, as if to let a group of workers build by laying bricks or stones wall, the foreman will pull a line as the criterion (baseline) to ensure the current this layer brick and tidy, test, too, have to test every hour, or you don't develop,

CodePudding user response:

references 9/f, interacting with professional developers response:
"that don't test this?" This kind of problem, you of the so-called "testing" is to finish writing the code in the hips, you are really gilding the lily, you don't feel pain, "" redundant"? The test code is often deceive ignorant of the director of test-driven development,

The real development, is don't know what to write, write tests first, and write "sick", to let the test can pass, each person every day when they have free run test hundreds of times, every change to run the test dozens of times to submit to the source code management system,

If you first write programs, for larger systems developers and architects, it's like a special forces do not have any action plan, is the small white die,

In fact, I am a halfway decent, for big companies process is not understand,
My understanding is that ah,
Such as: I write tests first, I think of is type a, through a certain algorithm output B, expectations C actually wrote the output in the process of the algorithm such as the test like that, that I am writing the program is also taken directly or function in this algorithm, the individual feels as
by the way, any good article, can post a link to come over, I'll see if

CodePudding user response:



A Basic the Introduction To c # Unit Test For Beginners

CodePudding user response:

11 references on the tip of the tongue of China's 001 reply:
I understand it is so of,
Such as: I write tests first, I think of is type a, through a certain algorithm output B, expectations C actually wrote the output in the process of the algorithm such as the test like that, that I am writing the program is also taken directly or function in the algorithm, when the individual feels the same

It is for personal matter of feeling, so is an engineering problem, is generally feel good for yourself whether, and feel of the project, is advantageous for the future, so not by feeling, truth is always stand in the side of a few people at the beginning, once everybody thinks he grasped the truth, that truth may also stinks, testing is a programmer how to improve the level, from beginners to the designer,

CodePudding user response:

Don't merely content with the practical to "know some concepts," knows "how" to acquire hands-on practice efficiency as a result, not just everyone saying says "what", this is the need to ponder practice spot, when your brain hasn't turned may also just stay in my brain chaozuoye phase with each other in the school class, you need to create and design of the project is too little, so much to write work plan, how to "spring do yourself project" checking, will know how to do after,

CodePudding user response:

The last say 1,

Actually I each sentence in answer to almost all test "is for the sake of what" problem, but this is a software engineering problem is the issue of human nature, to break the human nature of deception, to see the project,

CodePudding user response:

Write the code for so many years, haven't experienced test-driven development,
Feel this should be a good thing, but one is resistant to fit their heart to write unit tests, I think writing good code, run a few times also just passed, take the time to write the test case is too wordy, time may be too much, of course it is also because test-driven doing less, at the start of the low efficiency and methods may be incorrect, also makes the unit tests low profits, so difficult to insist,
In addition, I think if a person's development, there is no need for unit testing, anyway, I feel more freedom directly write code to run more convenient, efficiency is not low,

CodePudding user response:

Ask a question, giant programmers do unit testing? Who can say,

CodePudding user response:

cited the 17th floor of the knights templar 18 reply:
ask a question, giant programmers do unit testing? Who can say,
I also want to know, is a consortium to unit test

CodePudding user response:

I think it is right at least every public method - & gt;" Create a unit test ", each method can create multiple, from different dimensions,

As to meaning, one of which should be changed somewhere, don't need to bother to go to the other place will be wrong, as long as all run the unit tests can determine,

CodePudding user response:

references the 19th floor independent observers response:
I think it is right at least every public method - & gt;" Create a unit test ", each method can create multiple, from different dimensions,

As to meaning, one of which should be changed somewhere, don't need to bother to go to the other place will not be wrong, as long as all run the unit tests can determine,


This is actually a tool of the stunt, the actual development of little use, test also is not necessarily "unit tests", because "unit" of the word itself is relatively low, from baseline to implement the product demand, away from the day-to-day development task acceptance requirements, is a pure empty computer field,

Test drive according to each programmer to get a task to write, according to the testers to bug to write, according to the requirements analysis and acceptance test cases to write, to the daily work according to the technical manager plans to write, according to the programmer to is in charge of the daily work to plan to write, what is "unit tests"? What is called "for each method to create a test"? This is putting the cart before the horse of pure technology, the practice of building, rather than really agile and efficient testing technology,nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related