Ad
  • Default User Avatar

    Well, you can group tests into more test classes. To run it in embedded editor, you can wrap them into one suite, like:

    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    import static org.hamcrest.CoreMatchers.is;
    import static org.junit.Assert.assertThat;
    
    @RunWith(Suite.class)
    @Suite.SuiteClasses({
       MyTestSuite.MyTests.class,
       MyTestSuite.MyTests2.class
    })
    public class MyTestSuite {   
      
      public static class MyTests {
        @Test public void testIt() {
          assertThat(true, is(true));
        }
      }  
      
      public static class MyTests2 {
        @Test public void testIt2() {
          assertThat(false, is(false));
        }
      }
    }
    
  • Default User Avatar

    FYI: I was able to submit my solution after commenting out my test method

  • Default User Avatar

    True, but an array can be initialized with null, then you will get NullPointerException:

    String[] test = null;

    and considering there was a test

    @Test
    public void validateNull() {
    	assertNull(SmashWords.smash(null));
    }
    

    i'd go for a null check before returning.

  • Custom User Avatar

    One of the assumptions in the details was the you were given an array.

  • Default User Avatar

    It can be done simply by lowering delta:

    assertEquals(5881.25D, Circle.area(43.2673), 0.001);
    

    or by comparing strings:

    assertEquals("5881.25", String.valueOf(Circle.area(43.2673)));
    
  • Default User Avatar

    Null check missing

  • Default User Avatar

    Conversion of array to list is needless here.

  • Default User Avatar

    It's probably bug in codewars (or in some specific library version). You should report it.

    Could you please change the assertion to this form, so we can submit our solutions:

    assertThat(CaffeineBuzz.caffeineBuzz(12), is("CoffeScript"));
    

    Thanks

  • Default User Avatar

    Well the root cause is extra 'e' in your assertion. When I run it outside codewars I get:

    org.junit.ComparisonFailure: 
    Expected :CoffeeScript
    Actual   :CoffeScript
    

    But I don't know, why it doesn't show the correct output here.

    FYI: if you use assertThat notation, it works OK ;)

    assertThat(CaffeineBuzz.caffeineBuzz(12), is("CoffeeScript")); //wrong test with extra 'e'
    
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    That error IS strange. Unfortunately I have no idea what to debug. Can you please share your code? You can mark it as a spoiler and it should stay hidden.

  • Default User Avatar

    @mcclaskc could you please check your submission tests? This error is really strange.

  • Default User Avatar

    Description upgraded.

  • Custom User Avatar

    Looks really good. One thing it is missing though is a translated Java example in the description. You can just add the java section below the ruby one in the markdown.

  • Default User Avatar

    Thank you! I'll stick toLowerCamelCaseFromNowOn ;)

  • Loading more items...