1 package com.simpligility.maven.plugins.android.standalonemojos;
2
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.List;
6
7 import org.junit.Ignore;
8 import org.junit.runner.RunWith;
9 import org.powermock.core.classloader.annotations.PrepareForTest;
10 import org.powermock.modules.junit4.PowerMockRunner;
11 import org.powermock.reflect.Whitebox;
12
13 import com.simpligility.maven.plugins.android.AbstractAndroidMojoTestCase;
14 import com.simpligility.maven.plugins.android.CommandExecutor;
15 import com.simpligility.maven.plugins.android.config.ConfigHandler;
16 import com.simpligility.maven.plugins.android.configuration.Program;
17 import com.simpligility.maven.plugins.android.standalonemojos.MonkeyRunnerMojo;
18
19
20
21
22
23
24
25 @Ignore("This test has to be migrated to be an IntegrationTest using AbstractAndroidMojoIntegrationTest")
26 @RunWith( PowerMockRunner.class )
27 @PrepareForTest(
28 { CommandExecutor.Factory.class, ConfigHandler.class } )
29 public class MonkeyRunnerMojoTest extends AbstractAndroidMojoTestCase< MonkeyRunnerMojo >
30 {
31 @Override
32 public String getPluginGoalName()
33 {
34 return "monkeyrunner";
35 }
36
37
38
39
40
41
42 public void testDefaultMonkeyRunnerConfig() throws Exception
43 {
44 MonkeyRunnerMojo mojo = createMojo( "monkey-runner-config-project0" );
45 final ConfigHandler cfh = new ConfigHandler( mojo, this.session, this.execution );
46 cfh.parseConfiguration();
47
48 Boolean monkeyrunnerSkip = Whitebox.getInternalState( mojo, "parsedSkip" );
49
50 assertTrue( "monkeyrunner skip parameter should be true", monkeyrunnerSkip );
51 }
52
53
54
55
56
57
58 public void testDefaultUnskippedMonkeyRunnerConfig() throws Exception
59 {
60 MonkeyRunnerMojo mojo = createMojo( "monkey-runner-config-project1" );
61 final ConfigHandler cfh = new ConfigHandler( mojo, this.session, this.execution );
62 cfh.parseConfiguration();
63
64 Boolean monkeyrunnerSkip = Whitebox.getInternalState( mojo, "parsedSkip" );
65 String[] monkeyrunnerPlugins = Whitebox.getInternalState( mojo, "parsedPlugins" );
66 List< Program > monkeyrunnerPrograms = Whitebox.getInternalState( mojo, "parsedPrograms" );
67 Boolean monkeyrunnerCreateReport = Whitebox.getInternalState( mojo, "parsedCreateReport" );
68
69 assertFalse( "monkeyrunner skip parameter should be false", monkeyrunnerSkip );
70 assertNull( "monkeyrunner plugins parameter should not contain plugins", monkeyrunnerPlugins );
71 assertNull( "monkeyrunner programs parameter should not contain programs", monkeyrunnerPrograms );
72 assertFalse( "monkeyrunner monkeyrunnerCreateReport parameter should be false", monkeyrunnerCreateReport );
73 }
74
75
76
77
78
79
80 public void testCustomMonkeyRunnerConfig() throws Exception
81 {
82 MonkeyRunnerMojo mojo = createMojo( "monkey-runner-config-project2" );
83 final ConfigHandler cfh = new ConfigHandler( mojo, this.session, this.execution );
84 cfh.parseConfiguration();
85
86 Boolean monkeyrunnerSkip = Whitebox.getInternalState( mojo, "parsedSkip" );
87 String[] monkeyrunnerPlugins = Whitebox.getInternalState( mojo, "parsedPlugins" );
88 List< Program > monkeyrunnerPrograms = Whitebox.getInternalState( mojo, "parsedPrograms" );
89 Boolean monkeyrunnerCreateReport = Whitebox.getInternalState( mojo, "parsedCreateReport" );
90
91 assertFalse( "monkeyrunner skip parameter should be false", monkeyrunnerSkip );
92 assertNotNull( "monkeyrunner plugins parameter should not contain plugins", monkeyrunnerPlugins );
93 String[] expectedPlugins =
94 { "foo" };
95 assertTrue( Arrays.equals( expectedPlugins, monkeyrunnerPlugins ) );
96 assertNotNull( "monkeyrunner programs parameter should not contain programs", monkeyrunnerPrograms );
97 List< Program > expectedProgramList = new ArrayList< Program >();
98 expectedProgramList.add( new Program( "foo", null ) );
99 expectedProgramList.add( new Program( "bar", "qux" ) );
100 assertEquals( expectedProgramList, monkeyrunnerPrograms );
101 assertTrue( "monkeyrunner monkeyrunnerCreateReport parameter should be false", monkeyrunnerCreateReport );
102 }
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135 }