[MUSIC]
>> Next up, Visual Studio fans,
it's time to talk about
turbocharging your testing environment.
Here to give us a quick demo of
some new enhancements to Visual Studio,
please welcome Kendra Havens and Mandy Whaley.
Hi ladies, how are you?
>> Hello.
>> So good, Sana.
>> Good to see you! Welcome to Microsoft Build.
>> Thanks. Great to see you.
>> Kendra, can you tell me what's new in testing land?
What have users has been seeing
about testing in Visual Studio?
>> Absolutely.
You actually want to jump into a video right now?
I have a code coverage demo for us.
>> Let's do it. We love demos.
>> Nice.
We now have cross-platform code coverage support
on Linux with .NET tests.
This is useful for developers
who need code coverage reports from WSL,
like I'm using here
or their CI/CD machine that are targeting Linux.
Currently we support Ubuntu
as you can see and also Alpine.
We have many more on the way including Fendora,
CentOS, OpenSUSE, Debian, and Mint.
Here I can run .NET test --collect code coverage
to generate a report,
and I get some feedback at the command line
and I can open this in Visual Studio
to view my code coverage report.
Once I do that, you can actually see a blue highlight for
what lines are covered by tests and red for what isn't.
You can see in my production code what's highlighted,
what's covered, and what's not.
I can also get feedback from
Linux servers running in Azure DevOps
with the same kind of command line,
and we're experimenting with
how to show of how a PR impacts code coverage,
which is a bit more interesting information than just
shooting for as sort of an arbitrary percentage.
I want to know how the new code is affecting my quality.
So what is the trend with these changes?
You can dig into details with what
lines are covered per file and whatnot.
As always, we're also making
unit testing in Visual Studio better.
A recent addition was allowing Console.WriteLine
to appear in the Test Explorer
to get a little extra detail for your tests,
and we have some smart truncation around
long log files that reduce freezes and get you unblocked,
and we've also preserved
things like clickable links, your SourceLink,
so you can easily navigate from the test details pane,
we have collapsible regions.
I can click that hyperlink that I have in my output
and it will open up for me,
so, all easy to navigate.
>> Awesome. It's really nice to hear
all the changes in Visual Studio for testing.
Drive it home,
why is code coverage so important for developers?
>> Absolutely. It's a helpful metric
to ensure better code quality,
and maybe not if you're
targeting an outright percentage,
but more of a trend to monitor
if you're building up technical debt or not.
We're trying to make it easy to get those metrics
for better code health from our tools.
>> Right. Code health is important.
All those changes you showed in Visual Studio
to make it easy to navigate
the output of your test is important.
We talked about unit testing in that demo,
but that's just one kind of testing.
Mandy, can you tell us about another kind of testing,
UI testing,
what's available out there for that right now?
>> Yes, absolutely.
We are working on the Playwright open source library.
This is a project to help developers with
end-to-end testing for modern web applications.
Playwright makes it really easy
to create your integration tests
and do that early in your development process
and get started testing across all the different browsers.
>> If I've never used Playwright before,
what's the easiest way to get started with it?
>> One of the great things about Playwright is that
it's really designed to be very developer friendly
and you can use it in whatever language
is your preferred language.
JavaScript, TypeScript, Python, Java,
C#, you can even use it with
the Test Explorer in Visual Studio.
The best way to find all the
information about Playwright is
at playwright.dev and there's quickstarts,
different things you can do
to start using it in your project.
But I'd love to show you a quick Playwright demo.
If we can hop into the demo.
>> Definitely, let's do it. We love demos.
>> All right. We're starting off in Visual Studio Code,
and I'm going to launch the Playwright code gen tools.
This is going to open up a window where you can see
the code being generated. We're doing it in JavaScript,
but we can choose what language we want.
We're going to actually navigate to the GitHub webpage
and you'll start seeing that code appearing,
it's recording our actions and creating test
based on things like navigating to the pet page,
entering things in the text box, clicking on elements,
and what's really nice about this
is it makes it easy for developers
to start building these end-to-end tests
early in the development process.
They don't have to learn a lot of new tools,
they can record something quick,
build it into their pipeline,
and then know as they're building and deploying
that their application's behaving
the way that they want it to.
Like I said again, you can see we're changing
languages so there's great support for Python,
Java, JavaScript, and C#.
>> All right. That's really awesome to hear.
As a developer, how can I go about
adding Playwright to one of my existing projects?
>> Yeah. You can use it from Visual Studio Code.
It also integrates with GitHub Actions,
and the Test Explorer in Visual Studio.
We are always working
with our community to improve Playwright.
If you go to playwright.dev,
give it a try and we'd love to hear your feedback about
what you need to help with your testing journey
and what we could add to Playwright
that would help you out.
>> All right. Like we said,
it's open source so you can give us your feedback.
Both of you, if you could give
one kind of best practice about testing
for Teams, what would that be?
>> I don't think I would say that
if you're really wanting to delight
your customers or users
and give them a great experience
you need high-quality code.
We're working on building developer friendly tools
that are going to help you do that.
>> All right. Thank you so much.
It was a pleasure having you on.
>> Thank you.
>> Pleasure to be here.
>> All right.