0

I prefer to use "almost TDD" in my daily workflow. And a few days ago I've faced this issue.

Imagine a command with such signature.

protected $signature = 'sync:store {--storeId= : Sync stores}';

In my test-suite I've added

   $this->artisan('sync:store', [
      '--storeId'  => [1],
   ]);

Everything is ok, BUT the next day command was NOT working. I've overlooked the * in my signature. That's why the test was green, but the option was not working.

Is there a way to verify, that exactly the array notation works as needed? Cause this is a real-life issue I have faced.

D.R.
  • 2,540
  • 3
  • 24
  • 49
  • Have you looked over [here](https://laravel.com/docs/5.7/console-tests) ? – Julien METRAL Feb 22 '19 at 09:48
  • I don't see a `*` in a signature? I see you testing a different command than the one you've posted though? – Loek Feb 22 '19 at 09:52
  • @Loek that's what I'm saying :) I have overlooked the `*` in `--storeId`. And now looks like there is NO way to test it. – D.R. Feb 22 '19 at 09:58
  • @JulienMetral yep. No what I'm asking about :D – D.R. Feb 22 '19 at 09:59
  • @Loek the problem is that the test is green even though the command is not working. – D.R. Feb 22 '19 at 09:59
  • @D.R. you need to add more code. I don't see signatures, I don't see missing `*`s and I don't see tests being asserted? – Loek Feb 22 '19 at 14:32
  • @Loek The first code block (in grey) is the signature. the second grey block is the test. You definitely should be able to see it :D – D.R. Feb 25 '19 at 11:29
  • But the signature is `sync:store` and the test is running `sync:shopify-store-order-transactions`? And ctrl + f `*` isn't returning anything in your code? – Loek Feb 25 '19 at 13:16
  • @Loek, oh, sorry :) Overlooked. I've updated the `artisan` command. And yes, you should NOT be able to see the `*`. And theoretically, the test should fail, but it passes. That's the issue. – D.R. Feb 25 '19 at 13:40
  • Does it pass though? Now you run the command and then... Nothing? The test doesn't assert anything. It just checks it can run the command and that's it AFAIK. In other words, the test might not fail but it might not pass either when you don't assert anything. Then it shows up as a completed test without checks. – Loek Feb 25 '19 at 15:18

0 Answers0