Skip to content
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

jr. dev attempt at writing j-unit tests for utility classes #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

deseraekaufman
Copy link

To begin I would like to say, I learned SO much while working on this, it was a valuable experience just in that regard alone.
Although I was not able to complete the task as assigned, I spent quite a bit of time on it and would like to share where I am at so far.

I have worked with J-unit testing, although my experience so far has been quite basic.
These utility classes contain some syntax that is a bit more advanced than what I have seen, so while
my attempts at writing these tests might look pitiful, I would like to explain my thought processes
and all the things that I have learned while tackling this assessment.

Glancing through the project at first, I was pretty overwhelmed - it is more complex than projects I've worked on, but decided to give it a shot anyway and tackle would I could. I went through much of the code and commented on new things I learned, as well as explaining concepts as I understand them at my junior level.

Hopefully you get a sense of where I am as a developer, although I haven't much experience yet, I am very eager to learn and tackle new challenges. Thank you for giving me that opportunity!

Here is an example of some of the tests that I have written in my experience.

method to be tested:

public Map<String, Integer> getCount(String[] words) {
	Map<String, Integer> output = new HashMap<>();
	if (words != null) {
		for (String word : words) {
			if (!output.containsKey(word)) {
				output.put(word, 1);
			} else {
				output.put(word, output.get(word) + 1);
			}
		}
	}
	return output;
}

}

my test:
WordCount testObj = new WordCount();
@test
public void test_word_count_happy_path(){

    String[] testArray = {"ba","ba","black","sheep"};

    Map<String,Integer> testMap = Map.ofEntries(
            Map.entry("ba",2),
            Map.entry("black",1),
            Map.entry("sheep",1));

    Map<String,Integer> resultMap = testObj.getCount(testArray);

    Assert.assertEquals(testMap,resultMap);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant