When writing unit tests, I want to reduce the cognitive load of the reader as much as possible. One thing I've noticed that bothers me is that the variable names of the thing that is being tested are often varying quite a bit in my and my teams code. The variable is often named similar to the component in question. As an example

class Car:
  def get_tires():
    return 4

class TestCar:
  def test_get_tires():
    car = Car()
    assert car.get_tires() == 4

this is totally OK when talking about small and clearly readable tests. But when moving to large test suits, I was wondering if it's a good idea to name the object being tested uniformly the same. So:

class TestCar:
  def test_get_tires():
    testee = Car()
    assert testee.get_tires() == 4

However, I've not found such a pattern being used very much on SO and it's sibling pages like SWE. What are the pros and cons of moving to such a convention?

  • Out of curiosity, what was wrong with my question? Is it not appropriate for the SWE community, did I do some formal mistake or are people not happy with it not being posted on SO instead? The reason I went for this community is that this is (1) much more of a taste discussion and (2) not a problem that needs solving. I'm trying to determine not only what the right term (apparently SUT) is but also what the reasons for and against this are. – pascalwhoop Jan 10 at 12:34
  • In my opinion, the question has a few red flags: 1) the questions about naming, which tend to be opinion based, I'll remind you that naming is hard 2) It can argued that it shows little or no research, 3) what you want to do can read as a code smell - not bad per se - (naming multiple things the same will make it hard to search for them... is there an ulterior motive to keep names consistent, like, for example: copy and paste? that would suggest you should be reusing more code). I did not down vote. – Theraot Jan 10 at 12:38
  • 1) agreed, thus the move away from SO. I believe discussing naming is valid and there must be a forum for it. There is no perfect naming but there is definitely a lot of bad ways to name which should be avoided. 2) I've tried to look for "names variables testing" and similar queries but didn't stumble on the ISTQB ressource. 3) Is exactly what I'd like to discuss. It is education to hear several perspectives on this. One dev's code smell is another dev's design pattern – pascalwhoop Jan 11 at 9:20
  • In general, stating what you did try in the question in encouraged, consider, for example, that adding what you did you search for would help people searching for the same thing find this question. By the way, if I recall correctly, down votes cannot be retracted unless the post is edited. I wish more people would state why they down vote, in particular when the post is from somebody new to the site... however forcing them to comment would end bad, we gotta live with it. About naming question, when related to code. are on-topic here, you may also find useful english.stackexchange.com – Theraot Jan 11 at 9:35

The closest term I know is SUT (System Under Test). I want to note that I have seen it used to refer to a whole module (like a dll), however you seem to call module to a class.

Regardless, I found the following:

The "system under test". It is short for "whatever thing we are testing" and is always defined from the perspective of the test. When we are writing unit tests the system under test (SUT) is whatever class (a.k.a. CUT), object (a.k.a. OUT) or method(s) (a.k.a. MUT) we are testing; when we are writing customer tests, the SUT is probably the entire application (a.k.a. AUT) or at least a major subsystem of it. The parts of the application that we are not verifying in this particular test may still be involved as a depended-on component (DOC).

-- xUnit Patterns.

Thus, we can have:

  • CUT (Class Under Test)
  • OUT (Object Under Test)
  • MUT (Method Under Test)
  • AUT (Application Under Test)

And SUT (System Under Test) in an umbrella term for all of them. Meaning that it is right regardless of whatever or not we agree on what module means in the given context.

  • I've also seen definitions of Component Under Test & Code Under Test for CUT. – Robbie Dee Jan 10 at 9:28
  • This seems to be the answer that I was looking for. – pascalwhoop Jan 10 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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