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

Skip to content

Commit 8072ce8

Browse files
authored
Merge pull request #305 from jgebal/feature/not_to_matchers
Added missing not_to_be_null and not_to_be_not_null matchers (for com…
2 parents 4b3ea3c + 91a74b8 commit 8072ce8

47 files changed

Lines changed: 251 additions & 70 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/expectations/ut_expectation.tpb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,19 @@ create or replace type body ut_expectation as
136136
ut_utils.debug_log('ut_expectation.to_be_not_null');
137137
self.to_( ut_be_not_null() );
138138
end;
139-
139+
140+
final member procedure not_to_be_null(self in ut_expectation) is
141+
begin
142+
ut_utils.debug_log('ut_expectation.to_be_null');
143+
self.not_to( ut_be_null() );
144+
end;
145+
146+
final member procedure not_to_be_not_null(self in ut_expectation) is
147+
begin
148+
ut_utils.debug_log('ut_expectation.to_be_not_null');
149+
self.not_to( ut_be_not_null() );
150+
end;
151+
140152
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is
141153
begin
142154
ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null)');

source/expectations/ut_expectation.tps

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ create or replace type ut_expectation authid current_user as object(
2121
final member procedure not_to(self in ut_expectation, a_matcher ut_matcher),
2222
final member procedure to_be_null(self in ut_expectation),
2323
final member procedure to_be_not_null(self in ut_expectation),
24+
final member procedure not_to_be_null(self in ut_expectation),
25+
final member procedure not_to_be_not_null(self in ut_expectation),
2426

2527
-- this is done to provide strong type comparison. other comporators should be implemented in the type-specific classes
2628
member procedure to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null),
@@ -37,7 +39,7 @@ create or replace type ut_expectation authid current_user as object(
3739
member procedure to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null),
3840
member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null),
3941
member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null),
40-
42+
4143
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null),
4244
member procedure not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null),
4345
member procedure not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null),

tests/RunAll.sql

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ exec ut_coverage.coverage_start_develop();
4242
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql
4343
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql
4444

45+
@@ut_expectations/ut.expect.not_to_be_null.sql
4546
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNotBoolean.sql
4647
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsNull.sql
4748
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_false.GivesFailureWhenExpessionIsTrue.sql
@@ -52,8 +53,7 @@ exec ut_coverage.coverage_start_develop();
5253
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql
5354
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql
5455
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql
55-
@@ut_expectations/ut.expect.to_be_null.GivesFailureWhenActualIsNotNull.sql
56-
@@ut_expectations/ut.expect.to_be_null.GivesSuccessWhenActualIsNull.sql
56+
@@ut_expectations/ut.expect.to_be_null.sql
5757
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.refcursor.GivesSuccessWhenCursorIsNull.sql
5858
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql
5959
@@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql
@@ -130,19 +130,26 @@ exec ut_coverage.coverage_start_develop();
130130
@@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql
131131
@@lib/RunTest.sql ut_reporters/ut_xunit_reporter.ProducesExpectedOutputs.sql
132132

133-
@@lib/RunTest.sql ut_run/ut.run.FailsToExecuteAnInvalidPackageBody.sql
134-
@@lib/RunTest.sql ut_run/ut_run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql
135-
@@lib/RunTest.sql ut_run/ut_run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql
136-
@@lib/RunTest.sql ut_run/ut_run.function.WithPackageName.ExecutesAllFromGivenPackage.sql
137-
--@@lib/RunTest.sql ut_run/ut_run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment
138-
@@lib/RunTest.sql ut_run/ut_run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql
139-
@@lib/RunTest.sql ut_run/ut_run.function.WithSuitePath.ExecutesAllFromGivenPath.sql
140-
@@lib/RunTest.sql ut_run/ut_run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql
141-
@@lib/RunTest.sql ut_run/ut_run.WithNoParams.ExecutesAllFromCurrentSchema.sql
142-
@@lib/RunTest.sql ut_run/ut_run.WithPackageName.ExecutesAllFromGivenPackage.sql
143-
--@@lib/RunTest.sql ut_run/ut_run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment
144-
@@lib/RunTest.sql ut_run/ut_run.WithSchemaName.ExecutesAllFromGivenSchema.sql
145-
@@lib/RunTest.sql ut_run/ut_run.WithSuitePath.ExecutesAllFromGivenPath.sql
133+
@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileList.sql
134+
@@lib/RunTest.sql ut/ut.run.AcceptsCoverageFileListWithSutePaths.sql
135+
@@lib/RunTest.sql ut/ut.run.AcceptsSutePaths.sql
136+
@@lib/RunTest.sql ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql
137+
@@lib/RunTest.sql ut/ut.run.function.AcceptsCoverageFileList.sql
138+
@@lib/RunTest.sql ut/ut.run.function.AcceptsCoverageFileListWithSutePaths.sql
139+
@@lib/RunTest.sql ut/ut.run.function.AcceptsSutePaths.sql
140+
@@lib/RunTest.sql ut/ut.run.function.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql
141+
@@lib/RunTest.sql ut/ut.run.function.WithNoParams.ExecutesAllFromCurrentSchema.sql
142+
@@lib/RunTest.sql ut/ut.run.function.WithPackageName.ExecutesAllFromGivenPackage.sql
143+
--@@lib/RunTest.sql ut.run/ut.run.function.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment
144+
@@lib/RunTest.sql ut/ut.run.function.WithSchemaName.ExecutesAllFromGivenSchema.sql
145+
@@lib/RunTest.sql ut/ut.run.function.WithSuitePath.ExecutesAllFromGivenPath.sql
146+
@@lib/RunTest.sql ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql
147+
@@lib/RunTest.sql ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql
148+
@@lib/RunTest.sql ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql
149+
--@@lib/RunTest.sql ut.run/ut.run.WithPackageName.ExecutesAllFromGivenPackageOnly.sql --TODO this one doesn't work at the moment
150+
@@lib/RunTest.sql ut/ut.run.WithSchemaName.ExecutesAllFromGivenSchema.sql
151+
@@lib/RunTest.sql ut/ut.run.WithSuitePath.ExecutesAllFromGivenPath.sql
152+
@@lib/RunTest.sql ut/ut.version.sql
146153

147154
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheSchema.sql
148155
@@lib/RunTest.sql ut_suite_manager/ut_suite_manager.configure_execution_by_path.PrepareRunnerForTheTopPackageByPath.sql
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
declare
2+
l_output_data dbms_output.chararr;
3+
l_num_lines integer := 100000;
4+
l_packages_reported integer := 0;
5+
begin
6+
--act
7+
ut.run(
8+
ut_sonar_test_reporter(), a_source_files => ut_varchar2_list(),
9+
a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb')
10+
);
11+
dbms_output.get_lines( l_output_data, l_num_lines);
12+
13+
for i in 1 .. l_num_lines loop
14+
if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\'
15+
or l_output_data(i) like '%tests/test_package_2.pkb%'
16+
or l_output_data(i) like '%tests/test_package_3.pkb%' then
17+
l_packages_reported := l_packages_reported + 1;
18+
end if;
19+
end loop;
20+
21+
if l_packages_reported = 3 then
22+
:test_result := ut_utils.tr_success;
23+
else
24+
for i in 1 .. l_output_data.count loop
25+
dbms_output.put_line(l_output_data(i));
26+
end loop;
27+
dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported);
28+
end if;
29+
end;
30+
/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
declare
2+
l_output_data dbms_output.chararr;
3+
l_num_lines integer := 100000;
4+
l_packages_reported integer := 0;
5+
begin
6+
--act
7+
ut.run(
8+
ut_varchar2_list('test_package_1','test_package_3'), ut_sonar_test_reporter(),
9+
a_source_files => ut_varchar2_list(), a_test_files => ut_varchar2_list('tests/test_package_1.pkb','tests/test_package_2.pkb','tests/test_package_3.pkb')
10+
);
11+
dbms_output.get_lines( l_output_data, l_num_lines);
12+
13+
for i in 1 .. l_num_lines loop
14+
if l_output_data(i) like '%tests/test_package_1.pkb%' escape '\'
15+
or l_output_data(i) like '%tests/test_package_2.pkb%'
16+
or l_output_data(i) like '%tests/test_package_3.pkb%' then
17+
l_packages_reported := l_packages_reported + 1;
18+
end if;
19+
end loop;
20+
21+
if l_packages_reported = 3 then
22+
:test_result := ut_utils.tr_success;
23+
else
24+
for i in 1 .. l_output_data.count loop
25+
dbms_output.put_line(l_output_data(i));
26+
end loop;
27+
dbms_output.put_line('Failed: not all package paths were found in the outputs. Expected 3, got '||l_packages_reported);
28+
end if;
29+
end;
30+
/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
declare
2+
l_output_data dbms_output.chararr;
3+
l_num_lines integer := 100000;
4+
l_packages_executed integer := 0;
5+
begin
6+
--act
7+
ut.run(ut_varchar2_list('test_package_1','test_package_3'),ut_teamcity_reporter());
8+
dbms_output.get_lines( l_output_data, l_num_lines);
9+
10+
for i in 1 .. l_num_lines loop
11+
if l_output_data(i) like '%Finished %''test\_package\_1''%' escape '\'
12+
or l_output_data(i) like '%Finished %''test_package_2''%'
13+
or l_output_data(i) like '%Finished %''test_package_3''%' then
14+
l_packages_executed := l_packages_executed + 1;
15+
end if;
16+
end loop;
17+
18+
if l_packages_executed = 3 then
19+
:test_result := ut_utils.tr_success;
20+
else
21+
for i in 1 .. l_output_data.count loop
22+
dbms_output.put_line(l_output_data(i));
23+
end loop;
24+
dbms_output.put_line('Failed: not all packages were found in the outputs. Expected 3, got '||l_packages_executed);
25+
end if;
26+
end;
27+
/

tests/ut_run/ut.run.FailsToExecuteAnInvalidPackageBody.sql renamed to tests/ut/ut.run.FailsToExecuteAnInvalidPackageBody.sql

File renamed without changes.

tests/ut_run/ut_run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql renamed to tests/ut/ut.run.WithGivenReporter.ExectutesAllInCurrentSchemaUsingReporter.sql

File renamed without changes.

tests/ut_run/ut_run.WithNoParams.ExecutesAllFromCurrentSchema.sql renamed to tests/ut/ut.run.WithNoParams.ExecutesAllFromCurrentSchema.sql

File renamed without changes.

tests/ut_run/ut_run.WithPackageName.ExecutesAllFromGivenPackage.sql renamed to tests/ut/ut.run.WithPackageName.ExecutesAllFromGivenPackage.sql

File renamed without changes.

0 commit comments

Comments
 (0)