Skip to content

Commit

Permalink
Using groovy for test
Browse files Browse the repository at this point in the history
  • Loading branch information
anaiberta authored Nov 26, 2024
1 parent edeac70 commit 556f8c2
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions test/com/genexus/FileHelperTest.groovy
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import static org.junit.Assert.*
import org.junit.Test
package com.genexus

import com.genexus.FileHelper

class FileHelperTest {
@Test
void testStandardizeVersionForSemVer() {
FileHelper fileHelper = new FileHelper()

// Test case 1: Standard version without label
String result1 = fileHelper.standarizeVersionForSemVer("1.3.5", "88", "")
assertEquals("1.3.88", result1)
static void main(String[] args) {
def instance = new FileHelper() // Create an instance of your class

// Define test cases
def tests = [
['1.3.5', '88', '', 0, '1.3.88'],
['2.1.5', '457', 'beta', 0, '2.1.0-beta.457'],
['1.3.5', '88', '', 100, '101.3.88']
]

// Test case 2: Version with 'beta' label
String result2 = fileHelper.standarizeVersionForSemVer("2.1.5", "457", "beta")
assertEquals("2.1.0-beta.457", result2)
// Run tests
tests.each { testCase ->
String version = instance.standarizeVersionForSemVer(testCase[0], testCase[1], testCase[2], testCase[3])
assert version == testCase[4] : "Expected ${testCase[4]}, but got ${version}"
}

// Test case 3: Increase major version by 100 without label
String result3 = fileHelper.standarizeVersionForSemVer("1.3.5", "88", "", 100)
assertEquals("101.3.88", result3)
println "All tests passed!"
}
}

0 comments on commit 556f8c2

Please sign in to comment.