Short answer: Yes
I have done this several times in CodedWebTests, but this could also be done in declarative WebTest. You can use the special PreWebTest event handler to create your signalR client and connect to your SignalR hub. What you decide to do with the signalR notification is up to you, but I like to save it in WebTestContext and also display it on the test results screen using the AddCommentToResult method.
hubConnection addToGroup , , , .
using Microsoft.AspNet.SignalR.Client;
public class SignalRPlugin : WebtTestPlugin
{
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
var hubConnection = new HubConnection("yourSignalRUrl");
var hubProxy = hubConnection.CreateHubProxy("notifications");
hubConnection.Start().Wait();
hubProxy.Invoke("addToGroup", "me");
hubProxy.On<string>("message", s =>
{
e.Webtest.AddCommentToResult(s);
e.Webtest.Context.Add("signalRMessages", s);
});
}
}
, .
public MyWebTest()
{
PreWebTest += new SignalRPlugin().PreWebTest;
}
, signalR, , , . WebTestContext "signalRMessages". -, , .
, CodedWebTests, - WaitForNotifications, , . , , , signalR. - WaitForNotification, WebTest.InternalSetOutcome(Outcome.Fail);