Browse files

Merge pull request #9 from NetPenguin/add-testcase-for-coverage

Add testcase.for coverage.
  • Loading branch information...
2 parents 19678cc + 745e2e5 commit 778cd07d1e33c506dfa60087f47baedc18370e5b @NetPenguin committed Oct 2, 2013
Showing with 62 additions and 0 deletions.
  1. +27 −0 t/07.uninvoked_method.t
  2. +35 −0 t/99.error.t
View
27 t/07.uninvoked_method.t
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+use t::Util qw(expect_fail);
+use Test::More;
+BEGIN {
+ use_ok('Test::EasyMock',
+ qw{
+ create_mock
+ expect
+ replay
+ verify
+ });
+}
+use Test::Exception;
+
+# ----
+# Tests.
+subtest 'expected but not invoke' => sub {
+ my $mock = create_mock();
+ expect($mock->foo);
+ replay($mock);
+ expect_fail { verify($mock) };
+};
+
+# ----
+done_testing;
View
35 t/99.error.t
@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+
+use Test::More;
+BEGIN {
+ use_ok('Test::EasyMock',
+ qw{
+ expect
+ replay
+ reset
+ verify
+ });
+}
+use Test::Exception;
+
+# ----
+# Tests.
+subtest 'specify object, but it is not a mock object.' => sub {
+ my $other = bless {}, '__DUMMY__';
+ dies_ok { expect($other) } 'expect';
+ dies_ok { replay($other) } 'replay';
+ dies_ok { reset($other) } 'reset';
+ dies_ok { verify($other) } 'verify';
+};
+
+subtest 'specify scalar' => sub {
+ my $other = 123;
+ dies_ok { expect($other) } 'expect';
+ dies_ok { replay($other) } 'replay';
+ dies_ok { reset($other) } 'reset';
+ dies_ok { verify($other) } 'verify';
+};
+
+# ----
+done_testing;

0 comments on commit 778cd07

Please sign in to comment.