Difference between unittest and pytest

Submitted 3 years, 6 months ago
Ticket #212
Views 358
Language/Framework Python
Priority Low
Status Closed

could any one explain clearly with examples
Submitted on Oct 06, 20

I didn't understand this question could you tell me clearly? - Soudhamini 3 years, 6 months ago

Are you getting any error ? As per the above code , it should give you the random selected number in Output !! - Unknown 3 years, 6 months ago

ok - Star 3 years, 6 months ago
add a comment

1 Answer

Verified

I think unittest is easier to read. For new testers, unittest is really easy. It is working out of the box. You depend on the Python implementation, but they will not change the interface coming years.

I like to organize my tests in such a way that I have maximum 1 test per file. In that case I don't depend on classes... but I import classes from every test to do stuff.

Some websites complain about colours in unittest is not possible. I think that is a joke, since my unittests create JUNIT output reports for Jenkins and others. There are great tools (even 1 file) to convert JUNIT to a website, that's not the responsibility of a test tool.

Also, some people complain you need a lot of code to start a unittest. I disagree, it takes 4 lines of code to create a unittest! But Pytest needs to know all the difficult annotations, which are not normal for a simple Python developer.

An important reasons also is that unittest will remain free. However, if you want to use pytest for some reason (bitbucket etc), there are tools to convert your tests and make the code less readable.

Submitted 3 years, 1 month ago


Latest Blogs