# |
Apr 17th 2019, 15:06 |
neon1024 |
Yes |
# |
Apr 17th 2019, 15:03 |
Coddyx |
Is this because I can't mock a return value of a function not directly called by the test? |
# |
Apr 17th 2019, 15:03 |
Coddyx |
But whatever I put in $this->returnValue the test always failed |
# |
Apr 17th 2019, 15:02 |
Coddyx |
$alertes = $this->getMockForModel('Alertes', ['get']); $alertes ->expects($this->once()) ->method('get') ->will($this->returnValue(false)); $this->get('/en'); $this->assertResponseCode(503); |
# |
Apr 17th 2019, 15:02 |
Coddyx |
ie |
# |
Apr 17th 2019, 15:02 |
Coddyx |
I also tried mocking the return value of the get method on the model |
# |
Apr 17th 2019, 15:02 |
Coddyx |
WHILE we're there |
# |
Apr 17th 2019, 15:02 |
Coddyx |
and |
# |
Apr 17th 2019, 15:02 |
Coddyx |
ok |
# |
Apr 17th 2019, 15:01 |
neon1024 |
It’d probably be the least amount of work |
# |
Apr 17th 2019, 15:00 |
Coddyx |
To switch the value for true and false |
# |
Apr 17th 2019, 15:00 |
Coddyx |
You suggest I hit the db before the true and false test for miantenance mode? |
# |
Apr 17th 2019, 15:00 |
Coddyx |
So for my specific test case |
# |
Apr 17th 2019, 15:00 |
Coddyx |
I understand |
# |
Apr 17th 2019, 14:59 |
Coddyx |
:) |
# |
Apr 17th 2019, 14:59 |
neon1024 |
https://www.reddit.com/r/Jokes/comments/a4a4jc/a_software_qa_engineer_walks_into_a_bar/ |
# |
Apr 17th 2019, 14:58 |
neon1024 |
Read about the man who walks into a bar and buys a beer ;) |
# |
Apr 17th 2019, 14:58 |
neon1024 |
There is a balance between critical path testing and testing every use-case |
# |
Apr 17th 2019, 14:57 |
neon1024 |
The npath complexity of a method would give you a guide on how many test-cases might be there |
# |
Apr 17th 2019, 14:57 |
neon1024 |
No, I wouldn’t rely on it. It is a nice guide to see which test-cases you might have missed |
# |
Apr 17th 2019, 14:56 |
Coddyx |
and you rely on code coverage to assert everything passes by where it should? |
# |
Apr 17th 2019, 14:55 |
neon1024 |
You only test your public api |
# |
Apr 17th 2019, 14:55 |
neon1024 |
Either your code or your tests, that is |
# |
Apr 17th 2019, 14:55 |
neon1024 |
It’s a code smell. Usually means you need to refactor |
# |
Apr 17th 2019, 14:54 |
neon1024 |
It is |
# |
Apr 17th 2019, 14:54 |
Coddyx |
What is your opinion on that |
# |
Apr 17th 2019, 14:54 |
Coddyx |
directly |
# |
Apr 17th 2019, 14:54 |
Coddyx |
I've read that's it is considered a bad practice to test a private method |
# |
Apr 17th 2019, 14:54 |
Coddyx |
While you're there |
# |
Apr 17th 2019, 14:53 |
Coddyx |
french looks not so bad :P |
# |
Apr 17th 2019, 14:53 |
neon1024 |
Désolé je ne parle pas français parce que je suis britannique |
# |
Apr 17th 2019, 14:52 |
neon1024 |
I wouldn’t ever do that. I’d add more data to the fixture and then select the correct data in the test-case |
# |
Apr 17th 2019, 14:52 |
Coddyx |
actually, do you speak french? i just saw you're from strasbourg |
# |
Apr 17th 2019, 14:51 |
Coddyx |
Is there a way to inject a value in fixture for a specific test? |
# |
Apr 17th 2019, 14:50 |
Coddyx |
But |
# |
Apr 17th 2019, 14:50 |
Coddyx |
I'll try it |
# |
Apr 17th 2019, 14:49 |
Coddyx |
that I could |
# |
Apr 17th 2019, 14:48 |
neon1024 |
I guess you could do a write to the test db at the start of the test-case? |
# |
Apr 17th 2019, 14:48 |
neon1024 |
If you expose the value in your code or inject it you’d be able to test it much esier |
# |
Apr 17th 2019, 14:48 |
Coddyx |
Like so far I have $records = [ ['maintenance' => 1] ]; |
# |
Apr 17th 2019, 14:48 |
neon1024 |
Well that’s trying to solve a problem in testing by having bad code |