raymond-jgler / java-class-jacksonizer

A tool to bulk annotate existing constructor with given annotations, or to add a default constructor to Java classes if without.
MIT License
3 stars 0 forks source link

Add unit test for isNoneBlank of stringUtils class #13

Closed hienkwan closed 10 months ago

hienkwan commented 11 months ago

This PR for adding unit test for isNoneBlank method in stringUtils

Participant : @trgpnt

hienkwan commented 11 months ago

I'm contemplating about establishing a well-defined testing structure for Strings,

  1. For test data : We can use a string randomizer to output a random string with a defined rule (blank, contains [aA-Zz] and [0-9] and [any special char], or contains only the defined characters we input ( only spaces , etc ), a partial-buildable string value might be necessary.
  2. For code structure: I'm considering on this template:
@Test
    public void testDummy() {
        int length = 10;
        boolean useLetters = true;
        boolean useNumbers = false;
        String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);

        final Function<String, Boolean> testNoneBlank = StringUtils::isNoneBlank;
        assertTrue(testNoneBlank.apply(generatedString));
    }

RandomStringUtils is imported from apache-commons-lang

I'm planning on BaseTest.java, TestCase.java classes as well.

sth like : https://examples.javacodegeeks.com/java-development/core-java/junit/junit-setup-teardown-example/ to be more readable and maintainable

We can make use of this, and better serve for other string-related method testing. What's your suggestion?

I'm contemplating about establishing a well-defined testing structure for Strings,

  1. For test data : We can use a string randomizer to output a random string with a defined rule (blank, contains [aA-Zz] and [0-9] and [any special char], or contains only the defined characters we input ( only spaces , etc ), a partial-buildable string value might be necessary.
  2. For code structure: I'm considering on this template:
@Test
    public void testDummy() {
        int length = 10;
        boolean useLetters = true;
        boolean useNumbers = false;
        String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);

        final Function<String, Boolean> testNoneBlank = StringUtils::isNoneBlank;
        assertTrue(testNoneBlank.apply(generatedString));
    }

RandomStringUtils is imported from apache-commons-lang

I'm planning on BaseTest.java, TestCase.java classes as well.

sth like : https://examples.javacodegeeks.com/java-development/core-java/junit/junit-setup-teardown-example/ to be more readable and maintainable

We can make use of this, and better serve for other string-related method testing. What's your suggestion?

It's good for me. So let's follow your suggestion

raymond-jgler commented 10 months ago

@hienkwan , please find and review the latest commit hash that addressed what we'd previously discussed in this PR. Thank you for your time.