+tes #16431 support for TestProbe with user-defined name
This commit is contained in:
parent
49d9082851
commit
f480989b25
6 changed files with 55 additions and 6 deletions
|
|
@ -285,6 +285,19 @@ public class TestKitDocTest {
|
|||
//#test-probe
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demonstrateTestProbeWithCustomName() {
|
||||
//#test-probe-with-custom-name
|
||||
new JavaTestKit(system) {{
|
||||
final TestProbe worker = new TestProbe(system, "worker");
|
||||
final TestProbe aggregator = new TestProbe(system, "aggregator");
|
||||
|
||||
assertTrue(worker.ref().path().name().startsWith("worker"));
|
||||
assertTrue(aggregator.ref().path().name().startsWith("aggregator"));
|
||||
}};
|
||||
//#test-probe-with-custom-name
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demonstrateSpecialProbe() {
|
||||
//#test-special-probe
|
||||
|
|
|
|||
|
|
@ -388,6 +388,11 @@ flow, a :class:`TestProbe` could be inserted as target of A, using the
|
|||
forwarding capabilities or auto-pilot described below to include a real B in
|
||||
the test setup.
|
||||
|
||||
If you have many test probes, you can name them to get meaningful actor names
|
||||
in test logs and assertions:
|
||||
|
||||
.. includecode:: code/docs/testkit/TestKitDocTest.java#test-probe-with-custom-name
|
||||
|
||||
Probes may also be equipped with custom assertions to make your test code even
|
||||
more concise and clear:
|
||||
|
||||
|
|
|
|||
|
|
@ -211,6 +211,16 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
//#test-special-probe
|
||||
}
|
||||
|
||||
"demonstrate usage of test probe with custom name" in {
|
||||
//#test-probe-with-custom-name
|
||||
val worker = TestProbe("worker")
|
||||
val aggregator = TestProbe("aggregator")
|
||||
|
||||
worker.ref.path.name should startWith("worker")
|
||||
aggregator.ref.path.name should startWith("aggregator")
|
||||
//#test-probe-with-custom-name
|
||||
}
|
||||
|
||||
"demonstrate probe watch" in {
|
||||
import akka.testkit.TestProbe
|
||||
val target = system.actorOf(Props.empty)
|
||||
|
|
|
|||
|
|
@ -443,6 +443,11 @@ message flow, a :class:`TestProbe` could be inserted as target of A, using the
|
|||
forwarding capabilities or auto-pilot described below to include a real B in
|
||||
the test setup.
|
||||
|
||||
If you have many test probes, you can name them to get meaningful actor names
|
||||
in test logs and assertions:
|
||||
|
||||
.. includecode:: code/docs/testkit/TestkitDocSpec.scala#test-probe-with-custom-name
|
||||
|
||||
Probes may also be equipped with custom assertions to make your test code even
|
||||
more concise and clear:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue