Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am wondering if there are any benefits / risks of (not) putting a licence on test code which mostly consists of unit tests. What do you think?

I am particularly interested in licensing under (L)GPL, Apache, MIT and BSD.

EDIT: The assumption is that non-test code is already published under some licence, but test code is not, so the question is whether to publish it and if so whether to put the same licence on it.

share|improve this question

migrated from stackoverflow.com Nov 5 '11 at 5:36

This question came from our site for professional and enthusiast programmers.

    
Wouldn't tests be considered facts/data, which aren't subject to copyright or licensing in the first place? It's legal to copy an API, and I would guess it's also legal to use the same tests to verify that the implementation is correct? –  endolith Dec 17 '13 at 20:58
add comment

8 Answers

In commercial world, most companies charge not only for the core product but also for the support. Most often support involves any form of help by means of tool or personal assistance, to be able to make the product usable or resolve any issues related to product.

By this token, code for testing the product equally qualifies a support tool and is an intellectual property in its own right. So it does deserve a license of it's own.

share|improve this answer
add comment

Why do you separate code and test?

I prefer a bundle of code and test. And this bundle should get the same license.

If somebody would like to get twice money, then you may make two packages - each with a license. For free software, I see no reason for two packages (unless it is a size problem).

share|improve this answer
add comment

I'm surprised that no-one has mentioned this already, but if you don't attach a license to your code, whether it be product or test code, then others have no rights over the code.

Licensing code is about giving rights to others that they would not normally have. Your test code is automatically covered by copyright (in most countries around the world) even if you don't explicitly attach a copyright notice. Being copyrighted, other people cannot use, distribute or derive from that code.

By attaching a license to your test code, you give people the right to use, distribute and/or modify that code in accordance with the license terms.

I would recommend that you distribute your test code with your product code, under the same license. This is simplest for everyone. It also means that if people want to submit patches to you, then they can run your unit tests before they sent you a patch, which should help weeding out patches which break things.

share|improve this answer
add comment

The test code has a lot of value, since it allows the user to check if your solution works in a given environnement. In my job (embedded software) the test suite is part of the contract. You should publish it with the same licence, because usage is similar:

  • if someone just uses your code, then he will run the tests

  • if someone wants to modify the code, he will probably have to modify some tests as well

share|improve this answer
add comment

IANAL, however:

  1. If you are licensing your code under GPL, then de facto your unit tests are also GPL as they're pretty useless without the main code
  2. If you're using Apache/BSD, the 'USE AT YOUR OWN RISK' provision. I'd slap a license file with the whole project and let the user figure out if it's for the code or the test code.
  3. If you use a commercial license and limit access to the code, why would you publish your tests in the first place? If you want to be sure, put a 'BY READING THE TEST CODE, YOU HEREBY AGREE TO GOUGE YOUR EYES' license and you're good to go.
share|improve this answer
add comment

The GCC compiler (mostly GPLv3 licensed) has a quite extensive test suite, which is distributed with the source code. (perhaps some test files are in the public domain, I really don't know their individual legal status).

Why would you want to distribute your test suite separately from your product?

share|improve this answer
add comment

It might be a possible business model so release a program as free software (GPL or whatever), but the appertaining unit tests under a commercial license. That way, if someone wants to release an improved version of your software (e.g. embedded in a device), he might be motivated to buy the unit test license for quicker and safer development.

share|improve this answer
add comment

If your unit tests are well done then they are a blueprint for reproducing your software. If you don't license them equivalently to the code you are inviting someone to just come along and re-implement whatever you did. If you are alright with that then don't bother licensing them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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