Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Unit Test SignalR #11052

Open
Tracked by #23357
BlueDragon709 opened this issue Feb 22, 2019 · 19 comments
Open
Tracked by #23357

How to Unit Test SignalR #11052

BlueDragon709 opened this issue Feb 22, 2019 · 19 comments

Comments

@BlueDragon709
Copy link

Doc request for unit testing signalr in a ASP.NetCore 2.2 app
I am currently working on a signalr application and I want to be able to test my hubs. I couldn't find any information about unit testing signalr in AspNetCore/SignalR. The only information that i could find was from 2013 for AspNet/SignalR and is pretty outdated.

I am sugesting to put the topic about unit testing signalr on this location:

Docs/ASP.NET/ASP.NET Core/ASP.NET Core 2.2/Real-time apps/Unit testing
or
Docs/ASP.NET/ASP.NET Core/ASP.NET Core 2.2/Test, debug and roubleshoot/Unit testing/signalr hubs

This topic will cover the following topics:
Testing of hubs, testing of groups and examples.

A rough outline:

  • Prerequisites
  • Testing hubs
    -- Using MSTest
    -- Using NUnit
    -- Using xUnit
  • Testing groups
    -- Using MSTest
    -- Using NUnit
    -- Using xUnit
  • Examples

I hope this gets added because there is not a lot of information on this topic.

@BlueDragon709 BlueDragon709 changed the title aspnetcore/signalr/ Tutorial for unit testing signalr Doc request: aspnetcore/signalr/ Tutorial for unit testing signalr Feb 22, 2019
@NightAngell
Copy link

I wrote lib (available via nuget) which provide support for unit testing in signalR core (both Hub (Hub<T>) and IHubContext<T> (IHubContext<T, P>) ). I wrote docs for it too then if you want you can easily use it. In short summary it provide preconfigured mocks which are auto set upped by testing framework (NUnit, xUnit, MsTest, but there is also info how to use it with custom testing framework in docs) and some helpful 'verify' methods. For testing hubs you need just add nuget to your project and inherit from provided by lib base class (there is also possibility to use it without base class, info in docs). I don't want duplicate docs, then if you are interested:

  1. Project site
  2. Docs

There are examples in docs too.

@Rick-Anderson Rick-Anderson added this to the Backlog milestone Feb 25, 2019
@Kiril1512
Copy link

Yes, this would be very helpful for developers not only for testing, but also do understand better SignalR through unit tests.

@chrispickford
Copy link

Adding my +1 as unit testing documentation would be extremely helpful.

@DennisvanBeelen
Copy link

Yes especially te proper way to mock Hubs and Clients would be super usefull.

@ivanrodriguezfernandez
Copy link

+1
Any news on this?

@segadora
Copy link

+1

1 similar comment
@jacekkulis
Copy link

+1

@bradygaster bradygaster changed the title Doc request: aspnetcore/signalr/ Tutorial for unit testing signalr How to Unit Test SignalR Sep 20, 2021
@petercwq
Copy link

petercwq commented Feb 3, 2022

+1

2 similar comments
@matsydoodles
Copy link

+1

@kacper-swoop
Copy link

+1

@HaroonSaid
Copy link

Any update Code Maintainers?

@mkstephenson
Copy link

We would find this very useful as well

@Diomedes1990
Copy link

yes, this would be great, I was trying with old documentation.

@fn-bruce
Copy link

+1

@sankarbha
Copy link

yes, pl. share any documentation or sample unit test projects. Thanks.

@postmeback
Copy link
Contributor

Any update ?

@eranbar
Copy link

eranbar commented Jun 20, 2023

any updates?

@WeihanLi
Copy link
Contributor

WeihanLi commented Dec 27, 2023

Any update?

Hope for the unit testing support not only for the server but also for the client

@DomenPigeon
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests