Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3bc635

Browse files
I refactored the old test for the expectation not_to_be_null
1 parent d36cc4c commit d3bc635

4 files changed

Lines changed: 240 additions & 20 deletions

File tree

old_tests/RunAll.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ exec ut_coverage.coverage_start_develop();
3939

4040
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTrace.sql
4141
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql
42-
@@ut_expectations/ut.expect.not_to_be_null.sql
4342
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql
4443
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql
4544
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql

old_tests/ut_expectations/ut.expect.not_to_be_null.sql

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
create or replace package body test_expec_not_to_be_null
2+
is
3+
4+
procedure execute_expectation(a_data_type in varchar2,
5+
a_data_value in varchar2)
6+
is
7+
l_execute varchar2(32000);
8+
begin
9+
-- arrange
10+
l_execute := ' declare
11+
l_expected '||a_data_type||' := '||a_data_value||';
12+
begin
13+
--act - execute the expectation
14+
ut3.ut.expect(l_expected).not_to_be_null();
15+
end;';
16+
17+
execute immediate l_execute;
18+
end;
19+
20+
procedure test_success_expectacion(a_data_type in varchar2,
21+
a_data_value in varchar2)
22+
is
23+
begin
24+
execute_expectation(a_data_type, a_data_value);
25+
26+
--assert - check that expectation was executed successfully
27+
ut3_latest_release.ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_success);
28+
29+
-- cleanup
30+
ut3.ut_expectation_processor.clear_expectations();
31+
end;
32+
33+
procedure test_failure_expectacion(a_data_type in varchar2,
34+
a_data_value in varchar2)
35+
is
36+
begin
37+
execute_expectation(a_data_type, a_data_value);
38+
39+
--assert - check that expectation was a failure
40+
ut3_latest_release.ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_failure);
41+
42+
-- cleanup
43+
ut3.ut_expectation_processor.clear_expectations();
44+
end;
45+
46+
procedure blob_not_null
47+
is
48+
begin
49+
test_success_expectacion('blob', 'to_blob(''abc'')');
50+
end;
51+
52+
procedure blob_0_lengt
53+
is
54+
begin
55+
test_success_expectacion('blob', 'empty_blob()');
56+
end;
57+
58+
procedure boolean_not_null
59+
is
60+
begin
61+
test_success_expectacion('boolean', 'true');
62+
end;
63+
64+
procedure clob_not_null
65+
is
66+
begin
67+
test_success_expectacion('clob', 'to_clob(''abc'')');
68+
end;
69+
70+
71+
procedure clob_0_lengt
72+
is
73+
begin
74+
test_success_expectacion('clob', 'empty_clob()');
75+
end;
76+
77+
procedure date_not_null
78+
is
79+
begin
80+
test_success_expectacion('date', 'sysdate');
81+
end;
82+
83+
procedure number_not_null
84+
is
85+
begin
86+
test_success_expectacion('number', '1234');
87+
end;
88+
89+
procedure timestamp_not_null
90+
is
91+
begin
92+
test_success_expectacion('timestamp', 'systimestamp');
93+
end;
94+
95+
procedure timestamp_with_ltz_not_null
96+
is
97+
begin
98+
test_success_expectacion('timestamp with local time zone', 'systimestamp');
99+
end;
100+
101+
procedure timestamp_with_tz_not_null
102+
is
103+
begin
104+
test_success_expectacion('timestamp with time zone', 'systimestamp');
105+
end;
106+
107+
procedure varchar2_not_null
108+
is
109+
begin
110+
test_success_expectacion('varchar2(4000)', '''abc''');
111+
end;
112+
113+
procedure null_blob
114+
is
115+
begin
116+
test_failure_expectacion('blob', 'null');
117+
end;
118+
119+
120+
procedure null_boolean
121+
is
122+
begin
123+
test_failure_expectacion('boolean', 'null');
124+
end;
125+
126+
127+
procedure null_clob
128+
is
129+
begin
130+
test_failure_expectacion('clob', 'null');
131+
end;
132+
133+
134+
procedure null_date
135+
is
136+
begin
137+
test_failure_expectacion('date', 'null');
138+
end;
139+
140+
141+
procedure null_number
142+
is
143+
begin
144+
test_failure_expectacion('number', 'null');
145+
end;
146+
147+
148+
procedure null_timestamp
149+
is
150+
begin
151+
test_failure_expectacion('timestamp', 'null');
152+
end;
153+
154+
155+
procedure null_timestamp_with_ltz
156+
is
157+
begin
158+
test_failure_expectacion('timestamp with local time zone', 'null');
159+
end;
160+
161+
162+
procedure null_timestamp_with_tz
163+
is
164+
begin
165+
test_failure_expectacion('timestamp with time zone', 'null');
166+
end;
167+
168+
169+
procedure null_varchar2
170+
is
171+
begin
172+
test_failure_expectacion('varchar2(4000)', 'null');
173+
end;
174+
175+
end test_expec_not_to_be_null;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
create or replace package test_expec_not_to_be_null
2+
is
3+
--%suite(expectations - not_to_ve_null)
4+
--%suitepath(utplsql.core.expectations.no_to_be_null)
5+
6+
--%test(test blob not null)
7+
procedure blob_not_null;
8+
9+
--%test(test blob with length 0)
10+
procedure blob_0_lengt;
11+
12+
--%test(test boolean not null)
13+
procedure boolean_not_null;
14+
15+
--%test(test clob not null)
16+
procedure clob_not_null;
17+
18+
--%test(test clob with length 0)
19+
procedure clob_0_lengt;
20+
21+
--%test(test date not null)
22+
procedure date_not_null;
23+
24+
--%test(test number not null)
25+
procedure number_not_null;
26+
27+
--%test(test timestamp not null)
28+
procedure timestamp_not_null;
29+
30+
--%test(test timestamp with local time zone)
31+
procedure timestamp_with_ltz_not_null;
32+
33+
--%test(test timestamp with time zone)
34+
procedure timestamp_with_tz_not_null;
35+
36+
--%test(test varchar2 not null)
37+
procedure varchar2_not_null;
38+
39+
--%test(test with null blob)
40+
procedure null_blob;
41+
42+
--%test(test with null boolean)
43+
procedure null_boolean;
44+
45+
--%test(test with null clob)
46+
procedure null_clob;
47+
48+
--%test(test with null date)
49+
procedure null_date;
50+
51+
--%test(test with null number)
52+
procedure null_number;
53+
54+
--%test(test with null timestamp)
55+
procedure null_timestamp;
56+
57+
--%test(test with null timestamp with local time zone)
58+
procedure null_timestamp_with_ltz;
59+
60+
--%test(test with null timestamp with time zone)
61+
procedure null_timestamp_with_tz;
62+
63+
--%test(test with null varchar2)
64+
procedure null_varchar2;
65+
end test_expec_not_to_be_null;

0 commit comments

Comments
 (0)