JUnit 4 Tutorial - Your first Java Unit Test

preview_player
Показать описание
In this video I explain how to use assertEquals in JUnit.
Рекомендации по теме
Комментарии
Автор

That's a great tutorial, just wanted to point one thing out: When you do these test units for live projects, always make a test case that fails first. That way you know the test works as it should and won't give you a false positive.

To take the method in this tutorial as an example, what if the method was written wrong, so that it just happens to toss back -20.0 without actually caring about what goes in to it? Then this test case would show positive without actually doing what you need it to do.
I know, bad example, but just remember most methods have more than 1 line of code in it and anything can go wrong. That's why we use test units in the first place!

morphman
Автор

I love how I'm a university student being taught by a kid. Good job and the future is bright young man!

jakubsz
Автор

Congratulations! You are a talented boy!! thanks for the video

COSMOPOLITANWORLD
Автор

You are a talent person... thnx for the video

SamiEltamawy
Автор

I'm sure you knew and just typed it out for instructional purposes, but for others who wander by... you can simplify the Unit test writing process by generating shells for your tests in Netbeans:
1. Add the jUnit library to your project's dependencies/build path"
2. Right-click on the top-level "src" package and select "Tools --> Create Tests"

BTW: nice video my goodness how old are you and already rocking out code, awesome!?!

BCmoney
Автор

Excellent. I am going to try to learn the junit song on my piano. 

michaeljoc
Автор

Good video. Clear and simple explanation.

MGL
Автор

Cheers for the video! Excellent presentation

chronopod
Автор

Loved this guy! Too much of positive energy! :D

Cheers!

dimitrioschatzidimitriou
Автор

I eat rice too. Btu I haven't fully committed to it yet :) love the series makes my learning jUnit more fun.

youeatmetube
Автор

Hey dude love love the channel! The music is the best part! I have a question regarding the use of unit tests that contain return types. How do you write a test the caters for this as all the tests I've seen contain a void method. Keep up the awesome work!

IamWhoISayIAmftwfg
Автор

Thanks, it was very helpful !!! and I love the ending song, something very original (y) ^^

sarraoula
Автор

Hey Ryan, you shouldn't be returning anything from your test. In the video, I test a "multiply" method -- that's an example of testing what's being returned from a function. Hope that helps somewhat!

Sorry I couldn't reply to your comment directly-- YouTube is bugged for some reason.

simplyianm
Автор

Any video on how to unit test service and DAO methods ? It'll be a great help thanks

zed
Автор

Nice, "import static"! Awesome

gatomas
Автор

i swear this kid is like a genius hacker

Garyq
Автор

Lol ... Awesome ending! And you helped me out on JUnits = Like.

sliderBro
Автор

cool video do you have any cheat sheets for junit 4 for an interview

alexandersharma
Автор

I eat a lot of rice too :D
Thanks for the tut men.

andoy_abarquez
Автор

Parents with high expectations that keep pushing thier children.

AeolusMN