testify Questions
2
Solved
I'm using testify for testing. I've set up a suite for my tests. However, I'm having trouble using the set up and tear down features when using table tests. Is this by design?
package workflows
im...
7
Is there an established best practice for separating unit tests and integration tests in GoLang (testify)? I have a mix of unit tests (which do not rely on any external resources and thus run reall...
Borodin asked 22/9, 2014 at 1:30
4
I'm setting unit test in golang.
But now I'm facing error when running go test -v.
I want to resolve this error and make test success.
article
├ client
├ api
│ ├ main.go
│ ├ contoroller
│ │ ...
Kopeisk asked 9/9, 2019 at 5:37
4
Solved
I am using testify to test my code and I want to check if a function was called.
I am doing the following:
type Foo struct {
mock.Mock
}
func (m Foo) Bar() {
}
func TestFoo(t *testing.T) {
m...
2
I'm running a test with multiple parameters in a for loop using go lang testing.
I ran into a situation where same return value (and first set) is returned every time the mock is called. What I w...
Unravel asked 22/9, 2017 at 22:43
1
Solved
Consider this unit test file in Go. I'm using github.com/stretchr/testify/mock package.
type Person struct {Name string; Age int}
type Doer struct { mock.Mock }
func (d *Doer) doWithThing(arg Pers...
Sagittate asked 12/7, 2021 at 15:17
1
The documentation for AssertExpectations says "AssertExpectations asserts that everything specified with On and Return was in fact called as expected. Calls may have occurred in any order." What if...
Shaftesbury asked 21/6, 2016 at 9:13
1
Solved
So I'm making unit test in golang using mockery and testify
The test code goes like this:
const bufSize = 1024 * 1024
var lis *bufconn.Listener
var mockAccountService = &mocks.AccountService{...
Antabuse asked 2/7, 2020 at 11:52
1
Solved
Function below describes how to mock using testify. args.Bool(0), args.Error(1) are mocked positional return values.
func (m *MyMockedObject) DoSomething(number int) (bool, error) {
args := m.Ca...
5
Solved
TLDR: gorilla/mux used to not offer the possibility to set URL Vars. Now it does, that's why the second-most upvoted answer was the right answer for a long time.
Original question to follow:
Here'...
Jellaba asked 23/12, 2015 at 11:57
1
Solved
From documentation:
https://godoc.org/github.com/stretchr/testify/assert#InDelta
InDelta asserts that the two numerals are within delta of each other
https://godoc.org/github.com/stretchr/tes...
2
I have setup a test suite for my struct (https://github.com/stretchr/testify#suite-package). Before I was able to run a single test by specifying just a pattern:
go test -v ./services/gateways/......
1
Solved
My import looks like this below:
import (
"testing"
"github.com/stretchr/testify/assert"
)
when I try try running 'go test' I get the error message:
cannot find package "github.com/stretchr/t...
1
© 2022 - 2024 — McMap. All rights reserved.