Skip to content

Vidya : TypeInformation #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__junit_junit_4_12.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zipocde.app</groupId>
<artifactId>typeinformation</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>typeinformation-lab</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
34 changes: 34 additions & 0 deletions src/main/java/Result.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Created by vidyachandasekhar on 5/7/17.
*/
public class Result {
private String failureTestDetails;

private String successTestsDetails;

public String getSuccessTestsDetails() {
return successTestsDetails;
}

public void setSuccessTestsDetails(String successTestsDetails) {
this.successTestsDetails = successTestsDetails;
}

public String getFailureTestDetails() {
return failureTestDetails;
}

public void setFailureTestDetails(String failureTestDetails) {
this.failureTestDetails = failureTestDetails;
}

@Override
public String toString() {
if (failureTestDetails != null) {
return failureTestDetails ;
} else {
return successTestsDetails;
}

}
}
35 changes: 35 additions & 0 deletions src/main/java/UnitCornTestRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.junit.Test;

import java.lang.reflect.Method;

/**
* Created by vidyachandasekhar on 5/7/17.
*/
public class UnitCornTestRunner {

public Result runTest(Class c, Method methodName) {
Result result = new Result();

try{
methodName.invoke(c.newInstance());
result.setSuccessTestsDetails("Test on method "+ methodName + " passed");
} catch (Throwable t){
result.setFailureTestDetails("Test on method "+ methodName + " failed" + " cause: "+ t.getCause().getMessage());
}

return result;
}

public String runTests(Class c) {
Method[] methods = c.getDeclaredMethods();
StringBuilder sb = new StringBuilder();
for (Method method : methods) {
if (method.isAnnotationPresent(Test.class)) {
Result testResultReport = runTest(c, method);
sb.append(testResultReport.toString());
}
}
return sb.toString();
}
}

Loading