You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
re-wrote tests to run on junit 5 jupiter; created custom exception type which is thrown for script loading errors; added feature to provide custom classloader to script loading
Copy file name to clipboardexpand all lines: README.md
+19-2
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ println(loadedObj.x)
33
33
// >> I was created in kts
34
34
```
35
35
36
-
As shown, the `KtsObjectLoader`class can be used for executing a `.kts` script and return its result. The example shows a script that creates an instance of the `ClassFromScript` type that is loaded via ``KtsObjectLoader`` and then processed in the regular program.
36
+
As shown, the `KtsObjectLoader` can be used for executing a `.kts` script and getting its result. The example shows a script that creates an instance of the `ClassFromScript` type that is loaded via ``KtsObjectLoader`` and then processed in the regular program.
37
37
38
38
### Executing scripts directly
39
39
@@ -49,8 +49,25 @@ println(fromScript)
49
49
50
50
### Application Area
51
51
52
-
You might want to use **KtsRunner** when some part of your application's source has to be outsourced from the regular code. As an example, you can think of an application that provides a test suite runtime. The actual test cases are provided by technical testers who write their test scripts using a **domain specific language** that is provided by the main application. Since you don't want testers to add source files (defining new test cases) to your application all the time, the test case creation is made in independent `.kts` (Kotlin Scripting) files in which the DSL is utilized by the testing team. The test suite main application can use the presented **KtsRunner** library for loading the test cases provided in `.kts` files and process them further afterward.
52
+
You might want to use **KtsRunner** when some part of your application's source has to be outsourced from the regular code. As an example, you can think of an application that provides a test suite runtime. The actual test cases are provided by a QA team which writes their test scripts using a **domain specific language** that is provided by the main application. Since you don't want QA to add source files (defining new test cases) to your application all the time, the test case creation is made via independent `.kts` (Kotlin Scripting) files in which the DSL is being utilized. The test suite main application can use the presented **KtsRunner** library for loading the test cases provided in `.kts` files and process them further afterward.
53
53
54
+
### Controlling the ClassLoader
55
+
56
+
When instantiating an `KtsObjectLoader`, you can provide an explicit classloader as shown in this test case:
57
+
58
+
```kotlin
59
+
@Test
60
+
fun`when passing a custom classloader, it should be used when loading the script`() {
61
+
val myCl =object:ClassLoader() {
62
+
overridefunloadClass(name:String?): Class<*> {
63
+
throwIllegalStateException()
64
+
}
65
+
}
66
+
assertExceptionThrownBy<IllegalStateException> {
67
+
KtsObjectLoader(myCl).load("anything")
68
+
}
69
+
}
70
+
```
54
71
## Getting Started
55
72
56
73
In your Gradle build, simply include the following repository and dependency:
0 commit comments