-
Notifications
You must be signed in to change notification settings - Fork 56
Testing
Ori Roth edited this page Apr 2, 2017
·
4 revisions
Testing has a substantial influence on the quality of a large-scale code and it improves dramatically the capabilities to maintain it.
On this WikiPage we would like to list our testing conventions and rules for the Spartanizer:
- All the Tippers and Bloaters should be covered with an appropriate Junit Test Class. The name of the class should be the name of the appropriate issue on GitHub.
- Test classes should be documented and explain what they check.
- For testing Tippers and Bloaters there are designated functions with the following syntax :
- trimmingOf/bloatingOf(original code) - original code is a string represent a code we want to trim of expand.
- gives(given code) - given code is the code we expect to get after trimming/expanding.
- stays - when we don't expect any trimming or expansion.
You may want to use gives few times to check few passes over the code.
- For testing bloaters which use binding, you can write a class which you want to test, make sure that the class extends MetaFixture, then pass to bloatingOf an instance of the class, after that, check the changes with givesWithBinding, you may want to specify also a specific method you would like to check on the class.
Here are few usage examples: For Tippers:
@Test public void issue158_3() {
trimmingOf("wizard.assertEquals(99*2, s_4x0_5x1.mean(), 1E-6);")//
.gives("wizard.assertEquals(198, s_4x0_5x1.mean(), 1E-6);")//
.stays();
}
For Bloaters:
@Test public void b1() {
bloatingOf("if(x!=0) x+=1; else if(x==1) x+=2; else x+=10; ")//
.gives("if(x!=0) x=x+1; else if(x==1) x+=2; else x+=10; ");
}
For Bloaters with binding:
@Test public void test3() {
bloatingOf(new Issue1040Aux()).givesWithBinding("int a() {int i;i=0;++i;return 0;}", "a")
.givesWithBinding("int b() {int i;i=0;++i;return 0;}", "b").givesWithBinding("int a() {int i;i=0;i++;return 0;}", "a")
.givesWithBinding("int b() {int i;i=0;i++;return 0;}", "b");
}
For more information, you may want to look over examples to tests under "tests" and over the implementation of the testing utils, which are well-documented.