Skip to content

Check not only a presence of an exception itself but also its message #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
17 tasks done
php-coder opened this issue Jul 18, 2018 · 1 comment
Closed
17 tasks done

Comments

@php-coder
Copy link
Owner

php-coder commented Jul 18, 2018

Here is how we can improve our unit tests:

                then:
-                       thrown IllegalArgumentException
+                       IllegalArgumentException ex = thrown()
+                       ex.message == 'Series id must be non null'

Here are the places that should be updated:

$ git grep -c 'thrown ' src/test/groovy
src/test/groovy/ru/mystamps/web/service/CategoryServiceImplTest.groovy:14
src/test/groovy/ru/mystamps/web/service/CollectionServiceImplTest.groovy:14
src/test/groovy/ru/mystamps/web/service/CountryServiceImplTest.groovy:15
src/test/groovy/ru/mystamps/web/service/CronServiceImplTest.groovy:1
src/test/groovy/ru/mystamps/web/service/ImageServiceImplTest.groovy:11
src/test/groovy/ru/mystamps/web/service/SeriesImportServiceImplTest.groovy:15
src/test/groovy/ru/mystamps/web/service/SeriesSalesServiceImplTest.groovy:6
src/test/groovy/ru/mystamps/web/service/SeriesServiceImplTest.groovy:21
src/test/groovy/ru/mystamps/web/service/SiteServiceImplTest.groovy:2
src/test/groovy/ru/mystamps/web/service/StampsCatalogServiceImplTest.groovy:7
src/test/groovy/ru/mystamps/web/service/SuspiciousActivityServiceImplTest.groovy:4
src/test/groovy/ru/mystamps/web/service/TransactionParticipantServiceImplTest.groovy:4
src/test/groovy/ru/mystamps/web/service/UserServiceImplTest.groovy:8
src/test/groovy/ru/mystamps/web/service/UsersActivationServiceImplTest.groovy:7
src/test/groovy/ru/mystamps/web/util/CatalogUtilsTest.groovy:1
src/test/groovy/ru/mystamps/web/util/PagerTest.groovy:4
src/test/groovy/ru/mystamps/web/util/SlugUtilsTest.groovy:1

Here is a one-liner that could be used to perform initial update of a file:

$ sed -i "s|\([\t]*\)thrown \(.*\)|\1\2 ex = thrown()\\n\1ex.message == 'XXX'|" /path/to/file

Progress:

  • CategoryServiceImplTest.groovy
  • CollectionServiceImplTest.groovy
  • CountryServiceImplTest.groovy
  • CronServiceImplTest.groovy
  • ImageServiceImplTest.groovy
  • SeriesImportServiceImplTest.groovy
  • SeriesSalesServiceImplTest.groovy
  • SeriesServiceImplTest.groovy
  • SiteServiceImplTest.groovy
  • StampsCatalogServiceImplTest.groovy
  • SuspiciousActivityServiceImplTest.groovy
  • TransactionParticipantServiceImplTest.groovy
  • UserServiceImplTest.groovy
  • UsersActivationServiceImplTest.groovy
  • CatalogUtilsTest.groovy
  • PagerTest.groovy
  • SlugUtilsTest.groovy
@php-coder php-coder self-assigned this Jul 18, 2018
php-coder added a commit that referenced this issue Jul 18, 2018
…t also its message.

Addressed to #925

No functional changes.
@php-coder php-coder added this to the next milestone Jul 18, 2018
@php-coder php-coder modified the milestones: next, 0.4 Feb 10, 2019
php-coder added a commit that referenced this issue Feb 10, 2019
… also its message.

Addressed to #925

No functional changes.
@php-coder php-coder changed the title Check not only presence of an exception itself but also its message Check not only a presence of an exception itself but also its message Feb 10, 2019
php-coder added a commit that referenced this issue Feb 10, 2019
… also its message.

Addressed to #925

No functional changes.
php-coder added a commit that referenced this issue Feb 10, 2019
… also its message.

Addressed to #925

No functional changes.
php-coder added a commit that referenced this issue Feb 12, 2019
… also its message.

Addressed to #925

No functional changes.
php-coder added a commit that referenced this issue Feb 12, 2019
…orrect exception for invalid input.

Prior this change, UnknownFormatConversionException: Conversion = ''' was thrown instead of raised
IllegalArgumentException.

Found during work on #925

No functional changes.
php-coder added a commit that referenced this issue Feb 12, 2019
… also its message.

Addressed to #925

No functional changes.
@php-coder
Copy link
Owner Author

It's fixed now.

php-coder added a commit that referenced this issue Feb 13, 2019
… also its message.

Follow-up to #925

No functional changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant