Comments (6)
So, the problem is that I have is that I have many tests that do a GET to check the state, POST to change the state, and GET to confirm the state changed. And if one of the GET fails, I don't know which one it is because there is no label and they look identical. So, it means always having to lookup the line number for failing tests, which is particularly time-consuming because this is used in continuous integration tests and so I have to first find the commit it is in so that the line number is correct. If you have any recommendations, I would greatly appreciate it. This tool has been wonderful to use as supports everything I could even think of asking.
from apitest.
That looks great!
from apitest.
Hey @archsword. The name is currently only used in reports, e.g. sequence diagrams. I think currently you'd identify failed tests using the standard go test name. If you aren't using the sequence diagrams it's probably easier to not use the New()
method, tbh it's not the nicest API and I added the Handler
method later to simplify creation, e.g
apitest.Handler(handler).
Post("/hello").
Body(`{"a": 12345}`).
Header("Content-Type", "application/json").
Expect(t).
Status(http.StatusOK).
End()
from apitest.
@archsword thanks for more info. Understood. I'll look into it and get back to you.
If you aren't already aware, Debug()
is very useful for getting some visibility into failing tests. It prints the http headers and payload of all interactions.
func TestApiTest_ResponseBody(t *testing.T) {
apitest.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`{"id": "1234", "name": "Andy"}`))
w.WriteHeader(http.StatusOK)
}).
Debug().
Get("/user/1234").
Expect(t).
Body(`{"id": "1234", "name": "Andy"}`).
Status(http.StatusOK).
End()
}
from apitest.
How about something like this? It'll require a little bit of a refactor but should be possible.
from apitest.
I have a branch with the changes if you want to take it for a spin, otherwise I think I'll look to merge it over the weekend some time.
https://github.com/steinfletcher/apitest/tree/feature/test-case-name
from apitest.
Related Issues (20)
- Can we replace *testing T with an interface? HOT 5
- How to set RemoteAddr? HOT 4
- Discussion/Question: Roadmap for end-to-end tests ref https://apitest.dev/docs/config#networking HOT 2
- Typo in start of apitest.dev/docs/reports#reports HOT 1
- option to output sequence diagram with custom name instead of hash HOT 3
- Provide an ability to define a remote address for a test HOT 2
- multipart/form-data sending file HOT 1
- [Question] Support for Fiber v2 HOT 5
- Adding custom context to Request HOT 3
- Failed test in VScode keep trying to open assert.go file HOT 3
- Problem when using a custom http.Roundtripper HOT 5
- Output sequence diagram with custom name instead of hash HOT 1
- Align mocks and assertion behaviour for `Header` method and support `HeaderRegexp`
- Example for Fiber HOT 6
- Site example HOT 1
- Site example HOT 5
- Dependabot can't resolve your Go dependency files
- Flow Testing in Table driven HOT 2
- Improvements to response headers assertion error messages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apitest.