In what situations unit testing should be avoided? [closed] - unit-testing

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
When is unit testing harmful? it can't be used in all situations and it should be selective, do you know situations when it should be avoided?

Unit tests should always be simpler than the productive logic which is tested. So if you have trivial logic which can only be tests with a lot of staging, I would avoid unit tests.
Unit tests can become a nightmare when they become a maintenance problem. Unless you are willing to just remove them as soon as it starts creating a lot of work. Clean unit test usually are less prone to maintenance problems. This is actually not an argument against unit tests, it is an argument for isolated, simple unit tests.

Related

Can you write a unit test for a unit test? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Kind of a meta question, but I was wondering if there would ever be cases where writing a unit test for a unit test would make sense.
You don't have to write a test for that, generally its considered Mutation Testing.
Mutation Testing is a type of software testing in which certain statements of the source code are changed/mutated to check if the test cases are able to find errors in source code. The goal of Mutation Testing is ensuring the quality of test cases in terms of robustness that it should fail the mutated source code.
From Guru99
There's a few well known examples,
PIT for Java
MytPy for Python
Stryker looks like its the one for Javascript.
You could write you own tests that mutate your code itself, but its sensible to use OSS projects and help contribute to them if theres any unique needs given the complexity of the area. You don't want to have to own your own mutating framework either and all the maintance with that.

I've noticed some engineers bootstrap containers, such as Spring / Mironaut in their Unit Tests. Unit Test or Integration Test? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm getting confused here. I am from the school of thought where a Unit Test is about testing the Class Under Test, and mocking out it's immediate collaborators (some exceptions to this general rule here!).
However, some of my colleagues have a slightly different opinion in that they feel it's okay to bootstrap a Dependency Injection container in a Unit Test. To me this feels like the test is testing more than the Class Under Test because the DI container can automagically inject other dependencies which are irrelevant to the test.

Is it acceptable to create unit tests only after qa testing is done? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I came to know that in some shops, code is developed first, given to QA for testing and then developers write unit tests for that code. Is this approach acceptable ? If yes, then what are the pros & cons ?
I got some clues in answers in an unrelated question : Is Unit Testing worth the effort?
But, I also need answers specifically for my question.
A lot of serious dev "shops" do this.
When you develop complex applications for a client you never actually "care" about simple unit tests, the ones you can write any day of the coding project. You have to "test at a coarser level of granularity" (32:30 in the video) and you generally want to test things that are not supposed to change so you don't write tests over and over again, when the architecture changes a bit.
To answer your question: creating unit tests at the end is a fail safe for later, when you fix bugs making sure they don't break existing client required functionality. Writing tests at the end also gives you the insight you need to write them, the client's wishes are known and not subject to change any more.
Bottom line: It's not a science, you only get good at it while doing it.
PS: Not a fan, but this one is "right on the money" https://www.youtube.com/watch?v=9LfmrkyP81M

Implementing TDD midway through a project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am currently at about the 50% point in a web app's development, getting to this point by rapidly coding followed by refactoring. After reviewing with the client again at this point, the scope of the project required for completion is clear and unlikely to change.
Is it advised at this point to start implementing tests? If so, do I create tests for the functionality already completed or prioritize TDD for the remaining parts of the application?
As mentioned in the comment by #zerkms it is usually advisable to use TDD for new functionality, and when you change existing behaviour.
To guard the functionality you currently have, use some integration tests and smoke tests for some typical, and crucial scenarios. Don't aim to achieve high coverage with these tests, as it will be to much of a burden to maintain them in the future. If you will be persistent at writing unit tests for discovered bugs and new stuff in time you will get high coverage.

QUnit vs Jasmine? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
What are the main differences between these two testing frameworks?
I am a totally new to Test Driven Development and starting from the very beginning.
QUnit is very easy to get started with, as you only need to include two files and a little bit of markup, then you can start writing tests.
Jasmine strength, afaik is its BDD-style syntax, if that is something that you prefer (probably not a selling point for you) and tight integration into Ruby/Rails tools.
In the end both get the job done. I recommend to start with QUnit. Once you're feeling comfortable, try Jasmine and check if the BDD style fits better. If it does and you still want to keep using QUnit, you can add Pavlov to the mix, which provides BDD-style methods for QUnit.