-
Notifications
You must be signed in to change notification settings - Fork 0
Unit testing
INV implemented a unit testing mechanism that allows the testing of your logics and a "breakpoint" debugging using your preferred IDE.
To start, take a look at this implementation from inv-public-repo.
inv-public-repo is the public REPO provided by peasoupio.
Start by extracting the following source using git: git clone https://github.com/peasoupio/inv-public-repo.git
Here, we will be using IntelliJ (learn more here)
We will import the net/http
subfolder from the sources.
Open your Project Structure panel (File>Project Structure) and import your Groovy library. For more help, take a look at https://www.jetbrains.com/help/idea/getting-started-with-groovy.html
Make sure your are using a JDK version >= 11
You must add inv-core to your module libraries.
Open the Module Settings panel pressing on F4.
Clicking on the Problems panel, you should see something similar to this:
To correct the problem, add io.peasoup:inv-core using the Maven library panel:
Select your preferred version, thou the newest is always recommenced:
At this point, you should have no problem and your module libraries panel should look like this:
Right-click on a test script, under the /test
folder, and choose either Debug or Run
IMPORTANT: For an efficient local execution, tests scripts should start with those lines:
@groovy.transform.BaseScript(io.peasoup.inv.testing.JunitScriptBase.class) import org.junit.Test import static org.junit.Assert.*
- First line will tell IntelliJ which base class to use, thus enabling the debugging feature.
- Second line is somewhat required by the
@Grab
statement. Mostly, it removes@Test
not found errors.- Third line add most of the Junit 4 asserting static methods.
IMPORTANT: Those lines are NOT MANDATORY for an actual run using CLI or Composer. Their added values are only for an enchanced development experience.
A Run execution would look like this:
A Debug, with a breaking point, would look like this: