Today I was reviewing code from one of our teams testing a MERGE procedure. Ignoring the potential issues in using T-SQL MERGE how do you approach MERGE testing? 3 separate tests (1 for each leg of the MERGE verb)? One test that exercises all 3 legs? Both? Something else entirely? What is your rationale?FWIW our developers are coached that tests are supposed to function as black boxes. Given X input the test should expect Y output. And the test cannot be cognizant of the logic in the object under test. Those seem like obvious considerations but TDDD is not as commonly taught/learned/used as TDD in other arenas.
--
You received this message because you are subscribed to the Google Groups "tSQLt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tsqlt+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/8d204bee-96e5-4d27-86af-72a991d25d63n%40googlegroups.com.
I’m interested in seeing how others answer. Personally, I would do a single AssertEqualsTable with records that exercise each of the legs and the data clearly explaining what each one expects. For example “Should be INSERTED” in one of the columns.
Larry Blake
--
You received this message because you are subscribed to the Google Groups "tSQLt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
tsqlt+un...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tsqlt/8d204bee-96e5-4d27-86af-72a991d25d63n%40googlegroups.com.
[External Email: This message has originated from an external source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.]
On 13 Jul 2021, at 15:29, Bryant McClellan <bryant.m...@doitbest.com> wrote:
Today I was reviewing code from one of our teams testing a MERGE procedure. Ignoring the potential issues in using T-SQL MERGE how do you approach MERGE testing? 3 separate tests (1 for each leg of the MERGE verb)? One test that exercises all 3 legs? Both? Something else entirely? What is your rationale?FWIW our developers are coached that tests are supposed to function as black boxes. Given X input the test should expect Y output. And the test cannot be cognizant of the logic in the object under test. Those seem like obvious considerations but TDDD is not as commonly taught/learned/used as TDD in other arenas.
G
Bryant McClellan
Senior
Solutions Architect
260.748.5393 (direct)
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAJ1xV3ga01%3DgONiUXY-aXd5mDdzfEw_UPpm-CSqxpgMitY0cug%40mail.gmail.com.
Adding to Dmitrij’s comment: yes, you test the behavior. So later if you refactor and stop using MERGE, the test still applies.
I still would use the AssertEqualsTable as mentioned earlier, and identify the different paths of logic in the data.
Larry Blake
From: ts...@googlegroups.com <ts...@googlegroups.com>
On Behalf Of Bryant McClellan
Sent: Tuesday, July 13, 2021 10:45 AM
To: ts...@googlegroups.com
Subject: Re: #tSQLt: Philosophical testing question
Sorry, I didn't mean to imply we are testing whether MERGE works. More that we are testing how competent our developers are at exercising it in meaningful ways to get predictable results.
G Bryant McClellan
Senior Solutions Architect
260.748.5393 (direct)
Do it Best Corp.
6502 Nelson Road | Fort Wayne, IN 46803
On Tue, Jul 13, 2021 at 10:31 AM Dmitrij Kultasev <dkul...@gmail.com> wrote:
I would guess that you don't need to test merge statement. You need to test behavior and that doesn't matter how it was implemented.
вт, 13 июл. 2021 г., 17:29 Bryant McClellan <bryant.m...@doitbest.com>:
Today I was reviewing code from one of our teams testing a MERGE procedure. Ignoring the potential issues in using T-SQL MERGE how do you approach MERGE testing? 3 separate tests (1 for each leg of the MERGE verb)? One test that exercises all 3 legs? Both? Something else entirely? What is your rationale?
FWIW our developers are coached that tests are supposed to function as black boxes. Given X input the test should expect Y output. And the test cannot be cognizant of the logic in the object under test. Those seem like obvious considerations but TDDD is not as commonly taught/learned/used as TDD in other arenas.
G
Bryant McClellan
Senior
Solutions Architect
260.748.5393 (direct)
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/MN2PR07MB65275B2D81B70D1AC9633D75E5149%40MN2PR07MB6527.namprd07.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAN3pJNU5CJDJjqTgp1OV4Jko3GOTGUwpC9u0Cfff0c1_ZE4Upw%40mail.gmail.com.
G
Bryant McClellan
Senior
Solutions Architect
260.748.5393 (direct)
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAAwA796opMK%2BoWC8t_LMnKcgO_jidxK4pKUiQ5Vy49b6pz0UAg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAN3pJNUO%2Bmi7sF2dkU1OFt_guVT%2BSJWu-B5T_zy32NmD-BwVHQ%40mail.gmail.com.
AssertEqualsTable does 2 things:
Larry Blake
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAAwA795WAshksbMU%2Bx9ER6JV-2p8Tmh3-M-EOVxPzo2pTc83Kw%40mail.gmail.com.
G
Bryant McClellan
Senior
Solutions Architect
260.748.5393 (direct)
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/MN2PR07MB65279576E6FE68A6E7AB731EE5149%40MN2PR07MB6527.namprd07.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tsqlt/CAN3pJNU5CJDJjqTgp1OV4Jko3GOTGUwpC9u0Cfff0c1_ZE4Upw%40mail.gmail.com.
Thanks
Sebastian
Dedicated to freeing your SQL
Sebastian Meine
+1-832-377-5489
seba...@sqlity.net
sqlity.net
llc
Quality for SQL