Kotlin + Power-Assert = ❤️ | Brian Norman

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024

ความคิดเห็น • 17

  • @krellin
    @krellin 3 หลายเดือนก่อน +10

    This is awesome, not just for test set but in main as well.
    I like to have a const val DEBUG boolean value that will do compiler time code elimination for all assertions in main code. This would let it print really useful fast fail errors when running in dev, and get rid of all that magic in prod.

    • @Amejonah
      @Amejonah 3 หลายเดือนก่อน

      Yes, a dev/release build system would be really nice!

    • @krellin
      @krellin 3 หลายเดือนก่อน +2

      @@Amejonah no its already in the language, if you define a final bool DEBUG and put some if statements behind that flag, then if its false at compile time then all those assertions behind those ifs just go away from the bytecode entirely...
      that allows you to enable or disable assertions depending on environment and have it completely erased from the bytecode if you desire performance...

    • @PairingWithDuncan
      @PairingWithDuncan 3 หลายเดือนก่อน +1

      Ironically I think that it’s in production that this technology will be most useful. When we write tests we usually know what failures we are looking for, but when an assertion fails in production it is by definition unexpected, and at that point we want to know as much as possible about the values that caused the failure.

    • @krellin
      @krellin 3 หลายเดือนก่อน

      @@PairingWithDuncan yes, i often leave assertions on in prod, if you do it right assertsions should not change behaviour of the system, and if you do not abuse them performance impact is amortised and very low.
      I only keep the option to disable them behind that if(DEBUG) so i can removed them if necessary, but its not necessary for the most cases.
      TigerBeetle team does the same, but no option to disable assertions.
      Very cool library, gonna use it for sure.

  • @cpepos
    @cpepos 3 หลายเดือนก่อน +2

    wow, and this is just the start of K2 😮

    • @PairingWithDuncan
      @PairingWithDuncan 3 หลายเดือนก่อน

      For the record the plug-in is also available for pre-2.0 compilers

  • @bitwisedevs469
    @bitwisedevs469 2 หลายเดือนก่อน +1

    I know from the start that the first example of presentation will be so relatable.

  • @haxidenti6001
    @haxidenti6001 24 วันที่ผ่านมา

    assertEquals? AssertSize AssertEmpty etc?

  • @eatthepi
    @eatthepi 3 หลายเดือนก่อน +1

    This technology is indistinguishable from magic!

  • @ArthurKhazbs
    @ArthurKhazbs 3 หลายเดือนก่อน +1

    Wow. I guess now there is no excuse to not write tests. Thank you, Power-Assert!

  • @chillbro2275
    @chillbro2275 หลายเดือนก่อน

    4:36 That's Cool!!

  • @КириллГамазков
    @КириллГамазков 2 หลายเดือนก่อน

    Finally, an argument for people sticking with Spok (which is waaaaay too magical) and it's assertion messages

  • @skarloti
    @skarloti 3 หลายเดือนก่อน

    That's amazing, but I'd rather not see the word Java.
    When will it be possible to do tests on pure Kotlin?

    • @PairingWithDuncan
      @PairingWithDuncan 3 หลายเดือนก่อน +1

      You can now, but I’m interested in why you think that you can’t?

    • @skarloti
      @skarloti 3 หลายเดือนก่อน

      @@PairingWithDuncan The examples that are demonstrated are on JVM and JUnit

    • @PairingWithDuncan
      @PairingWithDuncan 3 หลายเดือนก่อน +2

      @@skarloti yes, but I believe that Power Assert will work fine with Kotlin.test tests on other platforms