LocalServerPort class final

Marks a late int field that receives the port of the real server the test started.

Use it with @SpringBootTest(webEnvironment: WebEnvironment.randomPort) to call the application over a socket, for example with a Feign client or HttpClient. When no server runs, setting the field fails the test with a StateError.

@LocalServerPort()
late int port; // then call http://localhost:$port/api/books

Spring (Java): @LocalServerPort.

Constructors

LocalServerPort()
Marks the field.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited