Skip to content

Commit b27bb3b

Browse files
committed
Use a random port for mongo test to avoid conflict
1 parent ec60e69 commit b27bb3b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scala-libraries-persistence/src/test/scala/com/baeldung/scala/reactivemongo/ReactiveMongoUnitTest.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ import reactivemongo.api.Cursor
1616
import reactivemongo.api.bson.BSONDocument
1717
import reactivemongo.api.bson.collection.BSONCollection
1818

19+
import java.net.ServerSocket
20+
1921
class ReactiveMongoUnitTest
2022
extends AsyncWordSpec
2123
with Matchers
2224
with BeforeAndAfterAll
2325
with BeforeAndAfterEach {
2426

25-
val PORT = 27079
27+
private val serverSocket = new ServerSocket(0)
28+
val PORT: Int = serverSocket.getLocalPort
2629
val IP = "localhost"
2730

2831
val mongodInstance: ImmutableMongod = Mongod

0 commit comments

Comments
 (0)