Um.
FOR JAVA SOLUTION! I don’t know what language you are programming!
Well, I just read the Clean Code by one of Martins, a book that claims that the idea of refactoring test code to maintain cleanliness and readability is a great idea, really the goal. So striving for refactoring and keeping the code clean is good, not a dumb idea, as I thought at first.
But this is not what you requested, so let's take a snapshot of the answer!
I would save the db of your tests - or the last test result. With a little java annotation, you can do something like this:
@SuperTestingFramerworkCapable public class MyFancyTest { @TestEntry @Test public testXEqualsYAfterConstructors(){ @TestElement
ANYWAY, you will also need a superclass of the refusion and annotation class that will check this code. It may just be an extra step in your processing - write tests, go through this super processor, and then, if it passes, run the tests. And your super processor will use the MyFancyTest circuit
And for each member that you have in your class, it will use a new table - here the table (only) will be testXEqualsYAfterConstructors And this table will have columns for each element marked with the @TestElement annotation. And it will also have a column for @TheTest I suppose you just call the columns TestElement1, TestElement2, etc. Etc.
AND THEN, once he has installed all this, he will just save the variable names and the annotated @TheTest string. So the table will be
testXEqualsYAfterConstructors TestElement1 | TestElement2 | TheTest SomeObjectType X | SomeObjectType X | AssertTrue(X.equals(Y));
So, if the super processor goes and finds that the tables exist, then it can compare what is already with what is now in the code, and can raise a warning for each individual record. And you can create a new user - the administrator, who can receive the changes, and can check them, the type of crucible is normal, or not.
And then you can sell this solution to this problem, sell you a company for 100 million and give me 20%
Hurrah!
A slow day, here's the rational: yuor's solution uses a lot of the extra overhead, most damagingly, in the actual production code. Your prod code should not be bound to your test code, and it certainly should not have a random variable that is specific to the test. The next suggestion that I have with the code you provided is that your structure does not stop people violating the tests. In the end, you can do this:
@Test public void equalsIfSameObject() { Person expected = createPerson(); Person actual = expected; check(Person.FEATURE_EQUAL_IF_SAME_OBJECT); boolean isEqual = actual.equals(expected); assertThat(isEqual).isTrue(); }
But if I changed the last two lines of code in some "refactoring" of test classes, then your structure will report success, but the test will do nothing. You really need to make sure the warning is raised and people can look at the “difference”.
Then again, you can simply use svn or perforce and the crucible to compare and verify this material!
In addition, seeing that you are interested in a new idea, you will want to read about local annotations: http://stackoverflow.com/questions/3285652/how-can-i-create-an-annotation- processor, what-processes-a local variable
Um, so you might need to get this guy - see the last comment in the link above - you may need his own java compiler.
@Disclaimer If you create a new company with a code that largely follows the above, I reserve the right to 20% of the company if and when you cost more than 30 million at the time of my choice