hi my name is Julio Cel and in this
video I will show you how to do some
test driven development in Visual Studio
2010 and also how to associate your
source source code uh check-ins with
Team Foundation server or items now
remember that we are using H beta 2 of
Visual Studio 2010 and team Foundation
server
2010 okay so so far we have H planed our
our Sprint or iter
we have um a team project we have a team
ready to work so what we want to do now
as a first um coding task is to do some
test driven development you know uh this
approach to development means that you
will first create your tests and only
after creating the test you will start
writing some code so Vis Studio 2010 has
some very nice additions for doing this
kind of development
so how do we start on this let's go to
visual studio now for this session I
will be taking the role of the developer
and this will be hulas in the in this in
this demo so let's add the the team
project let's use the appropriate
credentials
okay so log it in as a developer I will
connect and I I want to do this because
first thing I want to do is to check
which are my tasks I have some test
assigned so far you can see this from
the query be from the team queries the
my test query is returning me three
tasks and the one that I want to start
with is the one that is called build the
book list screen okay so how do we do
this in the test driven development way
uh okay let's close let's just close
this oh sorry let's close this
and what we want to do is to create a
solution rank new solution let's go file
new
project okay and from the available
templates let's go
to uh Visual Studio Solutions let's pick
an appropriate directory for this I will
use this folder and let's call this
bookstore okay make sure you you check
this check mark at to solution control
okay bookstore and let's click
okay so now Visual Studio is asking us
for which H folder into the source
control we want to place this rank new
solution so let's say um in the source
control we will call this um source so
into in your Source control you will if
you go to the bookstore SL searce pad
you will find all the files related to
this solution so let's just click
okay okay so just to make sure uh we got
the idea let's go to Team Explorer okay
let's close more items and open source
control and you can see that inside
bookstore there's a new folder called
source and inside Source there's
bookstore dos solution okay the plus
sign means that these files are marked
for addition in the next checking but
they are not still over there they're
just it's like a mark on these files so
let's close that and what we need to do
this this time uh let's first create a
couple of projects okay first thing to
create is will be um class
Library okay this is the class Library
uh remember we have been a Windows
application uh bookstore Windows uh
client and we will basically use uh two
projects for this which will be a class
Library we will call business and a
Windows um WPF
application
ER to display all the all the data so
let's call this
bookstore
do
business
okay here hit
okay so now that we have that we will
also need some uh project for the tests
first let's just delete this class one
class we don't need that and let's add a
new
project we will go to test test project
and let's call
it bookstore.
tests okay
so we will start with um we will need to
get a list of all the books in the in
the database so how to do that well
let's figure it out in our unit test
so we get here a brand new file called
unit test
one okay we will just um we'll rename
this
one okay let's call it
we will be working on a book manager
class this book manager will be in
charge of retrieving and Performing all
the actions H towards the database so
let's call this bop bager
tests okay let's hit yes so the class is
also renamed and we already have some uh
method stop here and we will change this
into get
book
list do
not return n okay this is a very basic
test okay keep in mind this is a short
video so we will just we will just want
to get a list of the books and make sure
it is not null okay so to do this we
will just use
the let's
hit book manager okay the quick tip here
to use the suggestions from the
intelligence you can do control alt and
space bar okay this makes stuff easier
so let's say book bager
manager equals oh sorry book manager
okay you can see this small U indicator
here if you open it you can generate a
class for this uh book manager you can
just click here but we want to do this
generate new type over here because we
want to place this into the business
Library okay let's click create a new
file book manager CS okay so the book
manager class is already created if we
hit F12 we go to the book manager class
it is in the business Library okay back
in the test we say equals new book
manager okay and we want to get a list
of what of
books
okay we call it books and seems like we
we don't have a book class so we we want
to do is to generate a new type call it
a book Into The bookstore. Business
Library hit
okay so this is equals to
manager. get book list but again we
don't have this new method so maybe you
already know how to do this let's let's
just generate a meod stop for getbook
list and finally let's assert on
this okay is not
null okay so we want to make sure that
books is a not new H object basically so
now that we have this what we want to do
is try to see if this test will pass so
let's just right click run
tests okay this will build the solution
and you can see that the test is not
passing as expected if you right click
here and let's see for example view test
results details you can see that the
test method get book list not return
return n to reception not implemented
exception which is expected because we
have that into the getbook list
method
so given the very small amount of time
for this video this will be a two-part
post so this is the end of the first
part and in the second part you will see
how to actually fix this uh error we're
getting here and how to make this uh a
green uh passive test okay so see you in
next part
No comments:
Post a Comment