Skip to content

Commit

Permalink
Refactor StatusCodeSupplierSpec and update pom.xml
Browse files Browse the repository at this point in the history
Refactored StatusCodeSupplierSpec to initialize StatusCodeSupplier in a setup method and simplified exception handling. Updated pom.xml to include Spec.java files in the test scope. These changes make the test setup more clear and ensures all relevant test files are included during testing.
  • Loading branch information
Jegors Čemisovs committed Feb 24, 2024
1 parent b124798 commit 783d337
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
<include>**/*Test.groovy</include>
<include>**/*IT.groovy</include>
<include>**/*Test.java</include>
<include>**/*Spec.java</include>
<include>**/*IT.java</include>
</includes>
<statelessTestsetReporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class StatusCodeSupplierSpec extends Specification {
def httpResponse = Mock HttpResponse

@Subject
def statusCodeSupplier = new StatusCodeSupplier(httpClient)
StatusCodeSupplier statusCodeSupplier

void setup() {
statusCodeSupplier = new StatusCodeSupplier(httpClient)
statusCodeSupplier.blogUrl = 'https://localhost'
}

def "should return status code when getAsInt is called"() {
given:
Expand All @@ -33,9 +38,6 @@ class StatusCodeSupplierSpec extends Specification {
statusCodeSupplier.getAsInt()

then:
def exeption = thrown(RuntimeException)

and:
exeption.cause instanceof IOException
thrown RuntimeException
}
}

0 comments on commit 783d337

Please sign in to comment.