Home > other >  Unit tests and Mock
Unit tests and Mock

Time:10-12

Simple function unit testing, I understand, but about the Mock, I always don't understand the use of it,
Mock one function is used to simulate some complex object, so my question is this:
1. If A function get_from_A need incoming parameters A, b is A complex object, then the various attributes from A to b,
A. one of the attributes may also be A complex object B, we also need to get the properties of the B

` ` `
Def get_from_A (A)
Assert (A.x, 1)//simply express
Assert (A.B.Y, "yy")
` ` `
My understanding is that need A A Mock object, then A object into the, but A object so complex, the object and object, this kind of circumstance can Mock? This function need unit tests?

2. About unit testing, such as the function of a function is to open a file, and then get file rows, so how to unit test of the function, need to really open a file?
  • Related