You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I write Go tests I usually do every time the same "setup" stuff:
There is some "class" (struct) with public method I want to test
It does have some interface deps that I mock with gomock and go generate
Then I setup my test functions (even though it has generated "skeleton")
I create "init mock" functions that do EXPECT and RETURN
I setup my callback function that checks whether those functions are initialized or not and calls them
Also creates gomock ctrl, calls my tested func and assert results
I think that ALL this stuff could (must actually) be automated. The only code that I really need to write as a developer is test cases. By test cases I mean: 1) name of the test case 2) what are inputs 3) mock programming 4) what are outputs. Sometimes there could (probably! I don't really used to do this) some "after" checks like whether some state was changed.
By "mock programming" I mean:
What deps are called
What are inputs of those calls
In what order they called (this is something that gomock ignores by default AFAIK)
What do they return
Can we make testing AS SIMPLE as possible with MINIMUM EFFORT from developer? Can we make ALL setup stuff pre-generated by default? Or automated somehow at least?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I write Go tests I usually do every time the same "setup" stuff:
I think that ALL this stuff could (must actually) be automated. The only code that I really need to write as a developer is test cases. By test cases I mean: 1) name of the test case 2) what are inputs 3) mock programming 4) what are outputs. Sometimes there could (probably! I don't really used to do this) some "after" checks like whether some state was changed.
By "mock programming" I mean:
Can we make testing AS SIMPLE as possible with MINIMUM EFFORT from developer? Can we make ALL setup stuff pre-generated by default? Or automated somehow at least?
Beta Was this translation helpful? Give feedback.
All reactions