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

Unit test framework for Blazor #5458

Closed
2 tasks
danroth27 opened this issue Jan 25, 2018 · 12 comments
Closed
2 tasks

Unit test framework for Blazor #5458

danroth27 opened this issue Jan 25, 2018 · 12 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Components Big Rock This issue tracks a big effort which can span multiple issues enhancement This issue represents an ask for new feature or an enhancement to an existing one
Milestone

Comments

@danroth27
Copy link
Member

  • Unit test helper for instantiating components and trying out events, etc.
  • End-to-end
@RehanSaeed
Copy link
Contributor

Please also consider snapshot testing, similar to Jest. I've been using it with Vue.js and I've found it to be a great way to test UI without being too fragile and needing constant fixing.

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@veikkoeeva
Copy link

veikkoeeva commented Jul 24, 2019

Probably under consideration, but it appears the end-to-end tests could work with Puppeteer.Sharp (ping @kblok, the Selenium libraries are also an option) using something like Razor Live Reload with the usual ways of starting a web server in tests. Then have examples how to collect performance numbers, test some CSS driven things, web components and Service Workers. Could be interesting to load tests dynamically so one could test mobile browsers too (especially performance).

Cypress and TestCafe could be some examples, albeit I'm not sure how much overlap there are with assertion libraries, like XUnit.

<Edit: One consideration is also isomorphic situations, one being something that can be run or mimicks environments like Cloudflare Workers, e.g. https://github.com/anywhichway/dexterous or https://github.com/envato/cloudflare-worker-test-harness .

@rjperes
Copy link
Contributor

rjperes commented Dec 19, 2019

Question: is this for publishing Microsoft.AspNetCore.Components.Testing?

@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, 5.0.0-preview1 Jan 10, 2020
@mkArtakMSFT mkArtakMSFT added the Components Big Rock This issue tracks a big effort which can span multiple issues label Jan 10, 2020
@SimonCropp
Copy link
Contributor

@RehanSaeed just an FYI, I maintain a snapshot style testing lib https://github.com/SimonCropp/Verify. and i am actively tracking blazor testing to see if i can add any specific value to that scenario. Happy to accept any suggestions you have

@mkArtakMSFT mkArtakMSFT changed the title Testing Unit test framework for Blazor May 5, 2020
@danroth27
Copy link
Member Author

Hi folks. At this point, we think providing testing framework support for Blazor is something that can best be handled by the Blazor open-source community. The bUnit project, for example, already provides support for unit testing components and implements many of the implementation ideas that we were exploring. Instead of building and supporting our own test framework, we prefer to encourage community innovation in this space, which allows us to focus our efforts on core framework improvements. Given this decision, I'm going to go ahead and close this issue.

@SimonCropp
Copy link
Contributor

FWIW i think this is a mistake. if you dont explicitly design for things to be testable (from an application perspective) then result will not be testable. and having the only test frameworks as downstreams means they will be too disconnected from you design process to give timely feedback.

@danroth27
Copy link
Member Author

If you don't explicitly design for things to be testable (from an application perspective) then result will not be testable. and having the only test frameworks as downstreams means they will be too disconnected from your design process to give timely feedback.

We certainly agree that Blazor needs to be designed to be testable, and we do consider testability in our design process. We of course welcome feedback in this area! As for whether test framework authors would be able to give us feedback in a timely fashion on design decisions, I think that should be possible by us continuing to do design and development in the open and also shipping frequent preview releases.

@SimonCropp
Copy link
Contributor

how about inviting the bunit team to merge projects and join the core blazor team

@SimonCropp
Copy link
Contributor

I think the disconnect is already apparent. eg the absence of testing from docs https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.1&tabs=visual-studio and many (other wise very complete) samples eg
https://github.com/dotnet-presentations/blazor-workshop

@githubfanster
Copy link

i was so looking forward to microsoft's own blazor testing framework (especially after i saw it included in the recently published roadmap).

is the bUnit project going to at least be a .Net Foundation supported project?
right now, it seems like mostly a one person project and i'm afraid of that kind of uncertainty

@danroth27
Copy link
Member Author

@SimonCropp We do have documentation gap on how to do component unit testing with Blazor. We've been tracking adding it for a while (dotnet/AspNetCore.Docs#10747), but we wanted to decide first whether we would be building a test framework or not (this issue). Now that we've decide to go with the existing community solutions, we've already started talking to the bUnit project owner about adding this content both to the docs and to the Blazor workshop. I don't think this reflects a disconnect with these community projects - it just reflects limited time and resources.

@githubfanster I brought this up with the bUnit owner earlier today as well. The thinking is that we will wait until bUnit hits 1.0, and then start the submission process.

@egil
Copy link
Contributor

egil commented May 16, 2020

@SimonCropp if time allows, I will contribute docs about testing and a lab to the Blazor Workshop, but as @githubfanster noticed, I'm just one person, so right now I am prioritizing getting bUnits own docs up to date for the beta-7 release.

@githubfanster I do want to move the project into the .net foundation as soon as possible. And I also welcome any form of help I can get with the project.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Components Big Rock This issue tracks a big effort which can span multiple issues enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

9 participants