Tag Archives: unit-тесты

Mock sql (sqlx) db on golang

I am using this library — https://pkg.go.dev/github.com/data-dog/go-sqlmock. That’s how you can use it for mocking db querying:

Mocking for unit-tests and e2e-tests in golang

Some patterns to test your golang app. Mocking an interface

https://github.com/vektra/mockery Mocking SQL database

https://github.com/DATA-DOG/go-sqlmock Mocking HTTP server for unit-tests

https://golang.org/pkg/net/http/httptest/ Stubbing HTTP server for e2e-tests

https://github.com/jmartin82/mmock Mocking for e2e-tests with dockertest

https://github.com/ory/dockertest

A way to test http client in go

A couple of ways are described here — http://hassansin.github.io/Unit-Testing-http-client-in-Go The way I liked is the following one:

Golang: testing http and grpc servers

HTTP server is quite easy to test — here is a nice video about it:

Tape: тестовый фреймворк без б

https://github.com/substack/tape Здесь рассказывают, чем он лучше Моки, Жасмина и прочих: https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4 Если коротко — прост в настройке, нет всяких хитрых сложных мокеров, вместо before/afterEach православные setUp/tearDown.

unit-тестирование AngularJS

http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-testacular.html — эту статью я уже упоминал; теория тестирования AngularJS. http://docs.angularjs.org/guide/dev_guide.unit-testing — небольшая и не слишком полезная официальная документация. http://karma-runner.github.io/0.8/index.html — инструмент для запуски автоматических тестов (как правильно подгружать внешние шаблоны). Примеры: https://github.com/vojtajina/ng-directive-testing https://github.com/angular/angular-seed https://github.com/IgorMinar/foodme/tree/master/test