How to halt on Test errors?
Hi Guys, Sometimes I'd like to stop my test suite when an error occurs. My raw approach is to put a self halt in the TestResult>>addError:Â and look at the debugger, but I'm wondering if there is a more suitable way. Can you help me, please? TIADavide
Hi Davide, Why not use one of the following: self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote:
Hi Guys,
Sometimes I'd like to stop my test suite when an error occurs.
My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way.
Can you help me, please?
TIA Davide
Hi Noury, You are right and reading your answer I understand I wasn't crystal clear. I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command.Is there anything like that in Pharo? TIA Davide On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote: Hi Davide, Why not use one of the following: self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Guys, Sometimes I'd like to stop my test suite when an error occurs. My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way. Can you help me, please? TIADavide
No ideas? CheersDavide On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Noury, You are right and reading your answer I understand I wasn't crystal clear. I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command.Is there anything like that in Pharo? TIA Davide On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote: Hi Davide, Why not use one of the following: self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Guys, Sometimes I'd like to stop my test suite when an error occurs. My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way. Can you help me, please? TIADavide
Hi Davide, I donât think something specific to your needs exists, but you can easily build your own. There is already for example `haltIfTest` that will halt if youâre in the dynamic extent of a test. If youâre dealing with concurrency issues, I donât understand how the `haltIfError` is actually helping you. Just running the test in debug mode is not enough? => it should open a debugger when it finds an error, right? G
El 8 ene. 2024, a las 09:54, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> escribió:
No ideas?
Cheers Davide
On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote:
Hi Noury,
You are right and reading your answer I understand I wasn't crystal clear.
I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command. Is there anything like that in Pharo?
TIA
Davide
On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote:
Hi Davide,
Why not use one of the following:
self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Guys,
Sometimes I'd like to stop my test suite when an error occurs.
My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way.
Can you help me, please?
TIA Davide
Hi Guillermo,There is no debug mode on test classes (see screenshot), it is at method level and unfortunately the error does not occur when I run the single test method, but when I ran the whole test class. How can I run the debugger at test class level? Cheers Davide On Monday, January 8, 2024 at 10:07:37 AM GMT+1, Guillermo Polito <guillermopolito@gmail.com> wrote: Hi Davide, I donât think something specific to your needs exists, but you can easily build your own.There is already for example `haltIfTest` that will halt if youâre in the dynamic extent of a test. If youâre dealing with concurrency issues, I donât understand how the `haltIfError` is actually helping you.Just running the test in debug mode is not enough? => it should open a debugger when it finds an error, right? G El 8 ene. 2024, a las 09:54, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> escribió: No ideas? CheersDavide On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Noury, You are right and reading your answer I understand I wasn't crystal clear. I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command.Is there anything like that in Pharo? TIA Davide On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote: Hi Davide, Why not use one of the following: self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Guys, Sometimes I'd like to stop my test suite when an error occurs. My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way. Can you help me, please? TIADavide
Hi David. Try to modify the method #runTestCase:results: to use "testCase suite debug" instead of #run: and you will switch to the debug mode. Then you can try to implement new command this way (copy ClyRunTestsFromClassesCommand as ClyDebugTestsFromClassesCommand and override some methods) пн, 8 Ñнв. 2024â¯Ð³. в 13:25, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org>:
Hi Guillermo, There is no debug mode on test classes (see screenshot), it is at method level and unfortunately the error does not occur when I run the single test method, but when I ran the whole test class.
How can I run the debugger at test class level?
Cheers
Davide
On Monday, January 8, 2024 at 10:07:37 AM GMT+1, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi Davide,
I donât think something specific to your needs exists, but you can easily build your own. There is already for example `haltIfTest` that will halt if youâre in the dynamic extent of a test.
If youâre dealing with concurrency issues, I donât understand how the `haltIfError` is actually helping you. Just running the test in debug mode is not enough? => it should open a debugger when it finds an error, right?
G
El 8 ene. 2024, a las 09:54, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> escribió:
No ideas?
Cheers Davide
On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote:
Hi Noury,
You are right and reading your answer I understand I wasn't crystal clear.
I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command. Is there anything like that in Pharo?
TIA
Davide
On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote:
Hi Davide,
Why not use one of the following:
self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote:
Hi Guys,
Sometimes I'd like to stop my test suite when an error occurs.
My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way.
Can you help me, please?
TIA Davide
You can implement another version of TestResult that halts when an error is added instead of recording it, and reimplement classForTestResult in the test cases to return this new class instead. On Mon, Jan 8, 2024 at 5:54â¯AM Davide Varvello via Pharo-users < pharo-users@lists.pharo.org> wrote:
No ideas?
Cheers Davide
On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote:
Hi Noury,
You are right and reading your answer I understand I wasn't crystal clear.
I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command. Is there anything like that in Pharo?
TIA
Davide
On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi < bouraqadi@gmail.com> wrote:
Hi Davide,
Why not use one of the following:
self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users < pharo-users@lists.pharo.org> wrote:
Hi Guys,
Sometimes I'd like to stop my test suite when an error occurs.
My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way.
Can you help me, please?
TIA Davide
Yes. Also you can try extending the current commands to get your âDebug Testsâ from the class side. And we accept contributions :)
El 8 ene. 2024, a las 14:31, Gabriel Cotelli <g.cotelli@gmail.com> escribió:
You can implement another version of TestResult that halts when an error is added instead of recording it, and reimplement classForTestResult in the test cases to return this new class instead.
On Mon, Jan 8, 2024 at 5:54â¯AM Davide Varvello via Pharo-users <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> wrote: No ideas?
Cheers Davide
On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> wrote:
Hi Noury,
You are right and reading your answer I understand I wasn't crystal clear.
I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command. Is there anything like that in Pharo?
TIA
Davide
On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com <mailto:bouraqadi@gmail.com>> wrote:
Hi Davide,
Why not use one of the following:
self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"
On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> wrote: Hi Guys,
Sometimes I'd like to stop my test suite when an error occurs.
My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way.
Can you help me, please?
TIA Davide
Hi Gabriel,Your answer leads back to my original question: how can I implement the "halt on error"? It is not clear to me. Cheers Davide On Monday, January 8, 2024 at 02:31:33 PM GMT+1, Gabriel Cotelli <g.cotelli@gmail.com> wrote: You can implement another version of TestResult that halts when an error is added instead of recording it, and reimplement classForTestResult in the test cases to return this new class instead. On Mon, Jan 8, 2024 at 5:54â¯AM Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: No ideas? CheersDavide On Thursday, January 4, 2024 at 03:42:17 PM GMT+1, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Noury, You are right and reading your answer I understand I wasn't crystal clear. I have a test scenario where sometimes a race condition occurs, so I'm not expecting any error. Which is why I'd prefer something built-in Pharo: a sort of "haltIfError" or "haltOnError" built-in command.Is there anything like that in Pharo? TIA Davide On Thursday, January 4, 2024 at 01:24:59 PM GMT+1, Noury Bouraqadi <bouraqadi@gmail.com> wrote: Hi Davide, Why not use one of the following: self should: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch"self shouldnt: ["message that might signal an error"] raise: Error "Replace Error with the exception you want to catch" On Jan 3 2024, at 4:55 pm, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: Hi Guys, Sometimes I'd like to stop my test suite when an error occurs. My raw approach is to put a self halt in the TestResult>>addError: and look at the debugger, but I'm wondering if there is a more suitable way. Can you help me, please? TIADavide
participants (5)
-
Davide Varvello -
Denis Kudriashov -
Gabriel Cotelli -
Guillermo Polito -
Noury Bouraqadi