(How) Do you test your dependencies in your unit-tests? [closed] - unit-testing

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Should you include testing external dependencies in your unit-tests, eg. not mocking the objects in the dependency but actually creating an instance in your unit-test as to ensure some third party didn't do something stupid like creating a BC-break in a patch release. If so, how do you do this? I can assume that automatically instantiating external code could lead to serious security vulnerabilities.

So after some great comments from #Nkosi I have come to the conclusion that this should not be a part of your unit-test suite. However to correctly test against deficiencies in external dependencies, integration tests should be set-up.
While looking into integration testing I came across a great answer about the balance between unit-tests and integration tests on StackExchange: https://softwareengineering.stackexchange.com/questions/208458/when-should-i-write-integration-tests#answer-208465

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.

Unit Testing Azure Function with Change Feed Trigger [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to write a unit test for an Azure Function with Change Feed Trigger.
Is it possible to trigger the function using document db emulator?
or
Should I call onto the function directly?
e.g., FunctionClass.Run(documents, null);
Also, is there any example on creating unit test for azure function?
I wasn't able to find any examples for similar cases.
Thanks
Unit testing means testing code in isolation, without dependencies on things like DB emulators.
So yes, just use your unit testing framework of choice and call Run directly, mocking any internal dependencies if needed.
You can find a couple examples in this repository.

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.