Replies: 2 comments 5 replies
-
I like the idea conceptually. However, I see an issue with the reproducibility of a test which uses this method as the setup might be different and the computer it runs on might not be as powerful as another dev‘s machine. |
Beta Was this translation helpful? Give feedback.
-
I agree with @Wulfheart above, but I would say that having the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes you want to test the performance of your application. For sure it's not real performance testing - but getting the duration of a request in your tests could be the first start.
The idea is to add a method
->duration()
on the\Illuminate\Testing\TestResponse
class which returns the duration of the request in microseconds.This would allow tests like the following - which checks that a heavy API endpoint is done within 3 seconds.
This could also be added as a general test for all your endpoints to be for example faster than half a second.
This would be a convenient shorthand done by the framework for the current option to do it:
The unit the duration is returned in would be to be defined - I just think that an integer is easier to test and read than a float.
A more limited solution but likely easier for most cases would be to add a
assertMaxDuration(CarbonInterval::seconds(3))
method. Possibly it would be even worth adding both as it's for thestatus
right now for example.More advancements could be to add similar methods to test memory usage and query count as well.
Beta Was this translation helpful? Give feedback.
All reactions