3

My code is something like:

function Controller(dep0, dep1) {
    dep0.call();
    dep1.call();
};

The test is something like:

function test() {
    dep0Mock = mock.create();
    controller = new Controller(dep0Mock, dep1Real);
};

2 Answers 2

3

For deciding if a test is a unit test or a functional test, I think I would consider the test's intent and how it is going to be used. I would look especially to practical differences caused by not mocking this dependency. Should this test be run frequently, or can it wait until after a new build is released to test? Does this test run quickly, even with the dependency? Is the dependency at least 99.9% reliable? Unit tests should be easy to run frequently, and they should very rarely fail unless there is a real bug. A unit test that fails due to a dependency is a problem.

However, this also depends on company culture, and I would recommend asking a more senior testing in your own company (if anyone is available). A good developer who has been there for a while might also have an opinion.

0
2

A unit test is a type of a functional test.

I am not sure what distinction you are trying to make, or why it is important to you.

5
  • Yes, the term 'functional test' is ambiguous. I'm differentiating between unit, functional, and system tests (all of which are functional tests since they're not non-functional tests) which differ in the scope of what they're testing. It's important to me because I feel names are important. As such, I tend to reflect the scope of the tests in the file's name.
    – Noel Yap
    Commented Aug 16, 2011 at 17:37
  • It seems to me you are mixing metaphors (e.g. Functional vs. Non-functional types of testing and unit and system 'levels' of testing). Commented Aug 17, 2011 at 5:01
  • The definition I'm using is en.wikipedia.org/wiki/Functional_test. I understand the valid use of the other definition, but that's not what I mean with my question. I don't want this question to get bogged down by definitions. Use whatever term will fit (Google uses Small, Medium, Large, and Enormous).
    – Noel Yap
    Commented Aug 17, 2011 at 16:16
  • 1
    I still do not understand why this is important to you. We divide things into categories because we believe we need to treat them differently. If introducing the mocking code changes categories, what does that imply to you? For example, does it mean that test responsibility moves from QA to dev? Does it mean that other QA guy should own the test? Does it mean you deserve a promotion?
    – user246
    Commented Aug 17, 2011 at 22:44
  • Who cares? A test provides value or it doesn't.
    – Squirrel
    Commented Aug 22, 2011 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.