yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00974
Subcommand testing
Hi Francesco,
I wanted to follow up with you and give everyone else a chance to weigh in on the questions I had about the way subcommand unit testing is being done. It just doesn't feel like we are accomplishing much.
In test_initlxc.py there is this code:
create_lxc_step = (
initlxc.create_lxc, ['lxc_name', 'lxc_arch', 'lxc_os', 'user'])
start_lxc_step = (initlxc.start_lxc, ['lxc_name'])
wait_for_lxc_step = (initlxc.wait_for_lxc, ['lxc_name', 'ssh_key_path'])
initialize_lxc_step = (
initlxc.initialize_lxc, ['lxc_name', 'ssh_key_path', 'lxc_os'])
setup_lxc_step = (
initlxc.setup_lxc, ['lxc_name', 'ssh_key_path', 'user', 'home_dir'])
stop_lxc_step = (initlxc.stop_lxc, ['lxc_name', 'ssh_key_path'])
[…]
expected_steps = (
test_inithost.initialize_step,
create_lxc_step,
start_lxc_step,
wait_for_lxc_step,
initialize_lxc_step,
setup_lxc_step,
stop_lxc_step,
)
The code being tested does this:
create_lxc_step = (create_lxc,
'lxc_name', 'lxc_arch', 'lxc_os', 'user')
start_lxc_step = (start_lxc,
'lxc_name')
wait_for_lxc_step = (wait_for_lxc,
'lxc_name', 'ssh_key_path')
initialize_lxc_step = (initialize_lxc,
'lxc_name', 'ssh_key_path', 'lxc_os')
setup_lxc_step = (setup_lxc,
'lxc_name', 'ssh_key_path', 'user', 'home_dir')
stop_lxc_step = (stop_lxc,
'lxc_name', 'ssh_key_path')
steps = (
inithost.SubCommand.initialize_step,
create_lxc_step,
start_lxc_step,
wait_for_lxc_step,
initialize_lxc_step,
setup_lxc_step,
stop_lxc_step,
)
and then in utils.py, the SubCommandTestMixin, basically compares the two.
To me this looks like we're creating a list in the code and then recreating and comparing the list in the test. Sure, that will cause a test failure if the list in the code changes but I don't feel there is much else being exercised.
It is possible I'm missing something fundamental but these tests just feel wrong to me.
Thoughts?
--Brad